<?php

namespace Kylin\Catering\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * 订单明细
 */
class OrderItem extends Model
{
    protected $table = 'catering_order_items';
    protected $fillable = [
        'order_id',
        'dish_id',
        'dish_name',
        'price',
        'quantity',
        'specifications',
        'remark',
        'status',
    ];

    protected $casts = [
        'order_id' => 'integer',
        'dish_id' => 'integer',
        'price' => 'decimal:2',
        'quantity' => 'integer',
        'specifications' => 'array',
    ];

    public function order(): BelongsTo
    {
        return $this->belongsTo(Order::class);
    }

    public function dish(): BelongsTo
    {
        return $this->belongsTo(Dish::class);
    }
}
