<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class OrderHistory extends Model
{
    use HasFactory;

    protected $table = "order_histories";
    protected $fillable = [
        'order_id',
        'order_item_category_id',
        'delivery_boy_id',
        'date',
        'status',
    ];

    protected $casts = [
        'id'                     => 'integer',
        'order_id'               => 'integer',
        'order_item_category_id' => 'integer',
        'delivery_boy_id'        => 'integer',
        'date'                   => 'datetime',
        'status'                 => 'integer',

    ];

    public function deliveryBoy(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(User::class, 'delivery_boy_id', 'id');
    }
    public function order(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(Order::class, 'order_id', 'id');
    }

    public function category(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(ItemCategory::class, 'order_item_category_id', 'id');
    }
}