10, 'order_number' => 10, 'customer_name' => 10, 'customer_email' => 5, 'notes' => 2, ]; public function user() { return $this->belongsTo('App\Models\Auth\User', 'customer_id', 'id'); } public function account() { return $this->belongsTo('App\Models\Banking\Account'); } public function currency() { return $this->belongsTo('App\Models\Setting\Currency', 'currency_code', 'code'); } public function category() { return $this->belongsTo('App\Models\Setting\Category'); } public function customer() { return $this->belongsTo('App\Models\Income\Customer'); } public function transfers() { return $this->hasMany('App\Models\Banking\Transfer'); } /** * Convert amount to double. * * @param string $value * @return void */ public function setAmountAttribute($value) { $this->attributes['amount'] = (double) $value; } /** * Convert currency rate to double. * * @param string $value * @return void */ public function setCurrencyRateAttribute($value) { $this->attributes['currency_rate'] = (double) $value; } public function scopeLatest($query) { return $query->orderBy('paid_at', 'desc'); } /** * Get the current balance. * * @return string */ public function getAttachmentAttribute() { if (!$this->hasMedia('attachment')) { return false; } return $this->getMedia('attachment')->last(); } }