belongsTo('App\User'); } public function setUserIdAttribute($value) { $this->attributes['user_id'] = $value ? $value : null; } public function setAgencyIdAttribute($value) { $this->attributes['agency_id'] = $value ? $value : null; } public function getDateAttribute($value) { return Carbon::parse($value)->format('d.m.Y.'); } public function setDateAttribute($value) { $this->attributes['date'] = $value ? Carbon::createFromFormat('d.m.Y.', $value) : null; } public function getDepositAttribute() { if (isset($this->paid)) { return $this->paid; } elseif (Request::has('paid')) { return Request::input('paid'); } else { return intdiv($this->price, 2); // if ($this->price < 100) { // return 5; // } else { // return floor($this->price / 100) * 10; // } } } public function getRemainingBalanceAttribute() { return $this->total_price - $this->total_deposit; } public function getTotalPriceAttribute() { return $this->type === 'oneway' ? $this->price : $this->price * 2; } public function getTotalDepositAttribute() { return $this->type === 'oneway' ? $this->paid : $this->paid * 2; } }