<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class PdOrder extends Model
{
    protected $table = 'pd_orders';

    protected $fillable = [
        'user_id','product_id','category_id',
        'qty','admin_price','reseller_price','sale_price',
        'wholesale_total','earn_total','grand_total',
        'size','color','delivery_payment_type','delivery_charge','delivery_charge_deducted',
        'customer_name','customer_phone','alt_phone',
        'address','division','district','thana','union_name','village',
        'status'
    ];

    protected $casts = [
        'qty' => 'integer',
        'admin_price' => 'decimal:2',
        'reseller_price' => 'decimal:2',
        'sale_price' => 'decimal:2',
        'wholesale_total' => 'decimal:2',
        'earn_total' => 'decimal:2',
        'grand_total' => 'decimal:2',
        'delivery_charge' => 'decimal:2',
        'delivery_charge_deducted' => 'boolean',
    ];

    public function product(){ return $this->belongsTo(Product::class); }
    public function user(){ return $this->belongsTo(User::class); }
    public function vendorOrder(){ return $this->hasOne(VendorOrder::class, 'pd_order_id'); }
}
