'integer', 'product_id' => 'integer', 'count' => 'integer', ]; public function order(): BelongsTo { return $this->belongsTo(Order::class)->withTrashed(); } public function getCount() { return $this->count; } public function product(): BelongsTo { return $this->belongsTo(Product::class)->withTrashed(); } public function getFinalPriceAttribute(): float { if (!empty($this->discount)) { return $this->discount; } else { return $this->price; } } public function getTotalPriceAttribute(): float { $price = $this->discount ?? $this->price; return $price * $this->count; } }