42 lines
808 B
PHP
42 lines
808 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class OrderItem extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'order_id',
|
|
'product_id',
|
|
'product_name',
|
|
'material',
|
|
'color',
|
|
'scale',
|
|
'infill',
|
|
'quantity',
|
|
'unit_price',
|
|
'total_price',
|
|
];
|
|
|
|
protected $casts = [
|
|
'unit_price' => 'float',
|
|
'total_price' => 'float',
|
|
'quantity' => 'integer',
|
|
];
|
|
|
|
public function order(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Order::class);
|
|
}
|
|
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
}
|