27 lines
574 B
PHP
27 lines
574 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class TransactionDetail extends Model
|
|
{
|
|
protected $fillable = ['transaction_id', 'product_id', 'quantity', 'price', 'subtotal'];
|
|
|
|
protected $casts = [
|
|
'price' => 'decimal:2',
|
|
'subtotal' => 'decimal:2',
|
|
];
|
|
|
|
public function transaction(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Transaction::class);
|
|
}
|
|
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
}
|