<?php

namespace App\Models;

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

class Booking extends Model
{
    use HasFactory;

    protected $fillable = [
        'cntr_no', 'customer_id', 
        'receiver_name', 'receiver_phone', 'receiver_city', 'receiver_cnic',
        'booking_date', 'pickup_date', 'delivery_date',
        'pickup_location', 'delivery_location', 'origin_city', 'destination_city', 'cargo_description',
        'weight_kg', 'volume_cbm', 'carton_count', 
        'weight_charge', 'volume_charge', 'carton_charge',
        'total_amount', 
        'advance_payment', 'due_payment', 'payment_status',
        'status', 'notes',
        'loading_date', 'shipping_date', 'discount'
    ];

    protected $casts = [
        'booking_date' => 'date',
        'pickup_date' => 'date',
        'delivery_date' => 'date',
        'weight_kg' => 'decimal:2',
        'volume_cbm' => 'decimal:2',
        'total_amount' => 'decimal:2',
        'advance_payment' => 'decimal:2',
        'due_payment' => 'decimal:2',
    ];

    public function customer()
    {
        return $this->belongsTo(Customer::class);
    }

    public function items()
    {
        return $this->hasMany(BookingItem::class);
    }

    public function tracking()
    {
        return $this->hasMany(ShipmentTracking::class);
    }
}
