56 lines
1.1 KiB
PHP
56 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Restaurant\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class OrderItem extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'restaurant_id',
|
|
'order_id',
|
|
'restaurant_id',
|
|
'food_item_id',
|
|
'food_variant_id',
|
|
'quantity',
|
|
'price',
|
|
'discount',
|
|
'tax',
|
|
'total',
|
|
'addons',
|
|
'meta',
|
|
'status',
|
|
'created_at',
|
|
'updated_at',
|
|
'deleted_at',
|
|
];
|
|
|
|
public const TABLE_NAME = 'order_items';
|
|
|
|
protected $table = self::TABLE_NAME;
|
|
|
|
protected $casts = [
|
|
'addons' => 'array',
|
|
'meta' => 'array',
|
|
];
|
|
|
|
public function order(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Order::class);
|
|
}
|
|
|
|
public function food(): BelongsTo
|
|
{
|
|
return $this->belongsTo(FoodItem::class, 'food_item_id');
|
|
}
|
|
|
|
public function variation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(FoodVariant::class, 'food_variant_id');
|
|
}
|
|
}
|