<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class PdOrderStatusHistory extends Model
{
    protected $table = 'pd_order_status_histories';

    protected $fillable = [
        'pd_order_id',
        'user_id',
        'admin_id',
        'admin_name',
        'action',
        'from_status',
        'to_status',
        'description',
        'user_message',
        'metadata',
    ];

    protected $casts = [
        'metadata' => 'array',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];

    public function order()
    {
        return $this->belongsTo(PdOrder::class, 'pd_order_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function admin()
    {
        return $this->belongsTo(Admin::class, 'admin_id');
    }
}

