format('d.m.Y'); } public function getPriceAttribute($price) { return Money::CHF($price)->format(); } public function documents() { return $this->morphMany(Document::class, 'documentable'); } public function contact() { return $this->belongsTo(Contact::class); } public function car() { return $this->belongsTo(Car::class); } public function scopeThisYear($query) { $query->where('date', '>', date('Y')); } public function scopeSoldThisYear($query) { $query->buyContracts()->thisYear(); } public function scopeBoughtThisYear($query) { $query->sellContracts()->thisYear(); } public function scopeBuyContracts($query) { $query->where('type', (string)ContractType::BuyContract); } public function scopeSellContracts($query) { $query->where('type', (string)ContractType::SellContract); } }