Skip to content

Commit

Permalink
Fix DRY - use traits instead
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardojbaez committed Jul 9, 2016
1 parent 7f5152c commit fa36929
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions src/Vehicle/Models/Vehicle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@
namespace Gerardojbaez\Vehicle\Models;

use Illuminate\Database\Eloquent\Model;
use Gerardojbaez\Vehicle\Contracts\HasMake as HasMakeContract;
use Gerardojbaez\Vehicle\Contracts\HasModel as HasModelContract;
use Gerardojbaez\Vehicle\Contracts\HasModelYear as HasModelYearContract;
use Gerardojbaez\Vehicle\Contracts\HasVehicle as HasVehicleContract;
use Gerardojbaez\Vehicle\Contracts\Vehicle as VehicleContract;
use Gerardojbaez\Vehicle\Traits\HasMake;
use Gerardojbaez\Vehicle\Traits\HasModel;
use Gerardojbaez\Vehicle\Traits\HasModelYear;
use Gerardojbaez\Vehicle\Traits\HasVehicle;

class Vehicle extends Model implements VehicleContract
{
use HasMake, HasModel, HasModelYear;

/**
* The attributes that are mass assignable.
*
Expand Down Expand Up @@ -38,36 +48,6 @@ protected static function boot()
});
}

/**
* Model belongs to one make.
*
* @return mixed
*/
public function make()
{
return $this->belongsTo(VehicleMake::class);
}

/**
* Model belongs to one vehicle model.
*
* @return mixed
*/
public function model()
{
return $this->belongsTo(VehicleModel::class);
}

/**
* Model belongs to one year.
*
* @return mixed
*/
public function year()
{
return $this->belongsTo(VehicleModelYear::class);
}

/**
* Scope by make.
*
Expand Down

0 comments on commit fa36929

Please sign in to comment.