<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class VendorOrder extends Model
{
    protected $fillable = [
        'pd_order_id',
        'product_id',
        'vendor_profile_id',
        'user_id',
        'order_no',
        'status',
        'total_amount',
        'tracking_link',
        'cancel_reason',
        'cancellation_requested_at',
        'cancellation_response',
        'admin_action_note',
        'admin_action_at',
        'ordered_at',
    ];

    protected $casts = [
        'pd_order_id' => 'integer',
        'product_id' => 'integer',
        'total_amount' => 'decimal:2',
        'cancellation_requested_at' => 'datetime',
        'admin_action_at' => 'datetime',
        'ordered_at' => 'datetime',
    ];

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

    public function product()
    {
        return $this->belongsTo(Product::class);
    }

    public function vendorProfile()
    {
        return $this->belongsTo(VendorProfile::class);
    }

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