From fa369298440e349255a835121cb3d8ec0007b30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerardo=20B=C3=A1ez?= Date: Fri, 8 Jul 2016 22:14:40 -0400 Subject: [PATCH] Fix DRY - use traits instead --- src/Vehicle/Models/Vehicle.php | 40 +++++++++------------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/Vehicle/Models/Vehicle.php b/src/Vehicle/Models/Vehicle.php index efda9d0..646f6d9 100644 --- a/src/Vehicle/Models/Vehicle.php +++ b/src/Vehicle/Models/Vehicle.php @@ -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. * @@ -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. *