2025-11-12 11:56:43 +05:30
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2025-12-01 10:38:52 +05:30
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
2025-11-12 11:56:43 +05:30
|
|
|
|
|
|
|
|
class Order extends Model
|
|
|
|
|
{
|
2025-12-01 10:38:52 +05:30
|
|
|
use HasFactory,SoftDeletes;
|
|
|
|
|
|
2025-11-12 11:56:43 +05:30
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-27 10:51:26 +05:30
|
|
|
// public function invoice()
|
|
|
|
|
// {
|
|
|
|
|
// return $this->hasOne(\App\Models\Invoice::class, 'order_id', 'id');
|
|
|
|
|
// }
|
2025-11-26 23:07:12 +05:30
|
|
|
|
|
|
|
|
|
2025-12-23 00:36:15 +05:30
|
|
|
const STATUS_LABELS = [
|
|
|
|
|
'order_placed' => 'Order Placed',
|
|
|
|
|
'order_confirmed' => 'Order Confirmed',
|
|
|
|
|
'supplier_warehouse' => 'Supplier Warehouse',
|
|
|
|
|
'consolidate_warehouse'=> 'Consolidate Warehouse',
|
|
|
|
|
'export_custom' => 'Export Custom',
|
|
|
|
|
'international_transit'=> 'International Transit',
|
|
|
|
|
'arrived_india' => 'Arrived at India',
|
|
|
|
|
'import_custom' => 'Import Custom',
|
|
|
|
|
'warehouse' => 'Warehouse',
|
|
|
|
|
'domestic_distribution'=> 'Domestic Distribution',
|
|
|
|
|
'out_for_delivery' => 'Out for Delivery',
|
|
|
|
|
'delivered' => 'Delivered',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function getStatusLabelAttribute()
|
|
|
|
|
{
|
|
|
|
|
return self::STATUS_LABELS[$this->status]
|
|
|
|
|
?? ucfirst(str_replace('_', ' ', $this->status));
|
|
|
|
|
}
|
2025-11-25 13:14:53 +05:30
|
|
|
|
2025-11-12 11:56:43 +05:30
|
|
|
}
|