Projects/3BIT/winter-semester/IIS/xnecasr00/app/Models/PurchaseItem.php
2026-04-14 19:28:46 +02:00

36 lines
747 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class PurchaseItem extends Model
{
use HasFactory;
protected $fillable = [
'purchase_id',
'wine_id',
'quantity',
'unit_price',
'line_total',
];
protected $casts = [
'quantity' => 'integer',
'unit_price' => 'decimal:2',
'line_total' => 'decimal:2',
];
public function purchase(): BelongsTo
{
return $this->belongsTo(Purchase::class, 'purchase_id');
}
public function wine(): BelongsTo
{
return $this->belongsTo(Wine::class, 'wine_id');
}
}