Skip to content

Commit

Permalink
Removed base model in favor to trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Isler committed Jul 20, 2017
1 parent d957f1c commit e38135d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
5 changes: 4 additions & 1 deletion database/Models/Car.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Spiritix\LadaCache\Tests\Database\Models;

use Spiritix\LadaCache\Database\Model;
use Illuminate\Database\Eloquent\Model;
use Spiritix\LadaCache\Database\LadaCacheTrait;

class Car extends Model
{
use LadaCacheTrait;

public function engine()
{
return $this->hasOne(Engine::class);
Expand Down
5 changes: 4 additions & 1 deletion database/Models/CarMaterial.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Spiritix\LadaCache\Tests\Database\Models;

use Spiritix\LadaCache\Database\Model;
use Illuminate\Database\Eloquent\Model;
use Spiritix\LadaCache\Database\LadaCacheTrait;

class CarMaterial extends Model
{
use LadaCacheTrait;

protected $table = 'car_material';
}
5 changes: 4 additions & 1 deletion database/Models/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Spiritix\LadaCache\Tests\Database\Models;

use Spiritix\LadaCache\Database\Model;
use Illuminate\Database\Eloquent\Model;
use Spiritix\LadaCache\Database\LadaCacheTrait;

class Driver extends Model
{
use LadaCacheTrait;

public function cars()
{
return $this->hasMany(Car::class);
Expand Down
5 changes: 4 additions & 1 deletion database/Models/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Spiritix\LadaCache\Tests\Database\Models;

use Spiritix\LadaCache\Database\Model;
use Illuminate\Database\Eloquent\Model;
use Spiritix\LadaCache\Database\LadaCacheTrait;

class Engine extends Model
{
use LadaCacheTrait;

public function car()
{
return $this->belongsTo(Car::class);
Expand Down
5 changes: 4 additions & 1 deletion database/Models/Material.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Spiritix\LadaCache\Tests\Database\Models;

use Spiritix\LadaCache\Database\Model;
use Illuminate\Database\Eloquent\Model;
use Spiritix\LadaCache\Database\LadaCacheTrait;

class Material extends Model
{
use LadaCacheTrait;

public function cars()
{
return $this->belongsToMany(Car::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Spiritix\LadaCache\Database;

use Illuminate\Database\Eloquent\Model as EloquentModel;
namespace Spiritix\LadaCache\Database;

/**
* Overrides Laravel's model class.
* Trait for overriding Laravel's query builder in models.
*
* This trait must be added to all models in a project, otherwise it might result in unexpected behavior.
* If Laravel would not have hardcoded the query builder class, this file would not be required anymore.
* It would also not be required to have all models extending this class.
*
* @package Spiritix\LadaCache\Database
* @author Matthias Isler <mi@matthias-isler.ch>
*/
class Model extends EloquentModel
trait LadaCacheTrait
{
/**
* Get a new query builder instance for the connection.
Expand Down

0 comments on commit e38135d

Please sign in to comment.