Files
Kent-logistics-Laravel/app/Models/Order.php

61 lines
1.2 KiB
PHP
Raw Normal View History

2025-11-12 11:56:43 +05:30
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
use HasFactory;
protected $fillable = [
2025-11-13 13:05:17 +05:30
'order_id',
'mark_no',
'origin',
'destination',
// totals only
'ctn',
'qty',
'ttl_qty',
'ttl_amount',
'cbm',
'ttl_cbm',
'kg',
'ttl_kg',
'status'
2025-11-12 11:56:43 +05:30
];
2025-11-13 13:05:17 +05:30
// One order has many items
public function items()
{
return $this->hasMany(OrderItem::class);
}
// Link using mark_no (optional)
2025-11-12 11:56:43 +05:30
public function markList()
{
return $this->hasOne(MarkList::class, 'mark_no', 'mark_no');
}
2025-11-21 16:07:43 +05:30
public function entries()
{
return $this->belongsToMany(Entry::class, 'entry_order', 'order_id', 'entry_id')
->withTimestamps();
}
2025-11-25 13:14:53 +05:30
public function shipmentItems()
{
return $this->hasMany(\App\Models\ShipmentItem::class, 'order_id', 'id');
}
public function shipments()
{
return $this->belongsToMany(\App\Models\Shipment::class, 'shipment_items', 'order_id', 'shipment_id');
}
2025-11-12 11:56:43 +05:30
}