add basic structure

shift-build-2464
Nadim Salloum 2021-05-10 19:05:46 +02:00
parent b62a7ffc4d
commit 38284947e0
1 changed files with 44 additions and 0 deletions

View File

@ -8,4 +8,48 @@ use Illuminate\Database\Eloquent\Model;
class Car extends Model
{
use HasFactory;
protected $fillable = [
'variation',
'variation',
'vin',
'colour',
'notes',
'known_damage',
'initial_date',
'bought_at',
'buy_price',
'seller_contact_id',
'car_model_id'
];
public function brand()
{
return $this->hasOneThrough(Brand::class, CarModel::class);
}
public function carModel()
{
return $this->belongsTo(CarModel::class);
}
public function seller()
{
return $this->belongsTo(Contact::class, 'seller_contact_id');
}
public function buyer()
{
return $this->hasOneThrough(Contract::class, Contact::class);
}
public function contract()
{
return $this->hasOne(Contract::class);
}
public function carPayment()
{
return $this->hasManyThrough(CarPayment::class, Contract::class);
}
}