62 lines
1.0 KiB
PHP
62 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ShipmentItem extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'shipment_id',
|
|
'order_id',
|
|
|
|
// OLD fields (keep them if old data exists)
|
|
'order_ctn',
|
|
'order_qty',
|
|
'order_ttl_qty',
|
|
'order_ttl_amount',
|
|
'order_ttl_kg',
|
|
|
|
// NEW fields (added for correct shipments)
|
|
'ctn',
|
|
'qty',
|
|
'ttl_qty',
|
|
|
|
'cbm',
|
|
'ttl_cbm',
|
|
|
|
'kg',
|
|
'ttl_kg',
|
|
|
|
'ttl_amount',
|
|
];
|
|
|
|
// ---------------------------
|
|
// RELATIONSHIPS
|
|
// ---------------------------
|
|
|
|
public function shipment()
|
|
{
|
|
return $this->belongsTo(Shipment::class);
|
|
}
|
|
|
|
public function order()
|
|
{
|
|
return $this->belongsTo(Order::class);
|
|
}
|
|
|
|
// Helper: return order data with fallback to snapshot
|
|
public function getDisplayQty()
|
|
{
|
|
return $this->qty;
|
|
}
|
|
|
|
public function getDisplayAmount()
|
|
{
|
|
return $this->ttl_amount;
|
|
}
|
|
}
|