'float', 'total' => 'float', 'amount' => 'float', ]; protected $appends = ['total']; protected $with = ['category']; public function scopeLines($query) { return $query->where('is_line', true); } public function category() { return $this->belongsTo(Category::class); } public function getTotalAttribute() { return round($this->price * $this->amount, 2); } }