38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\Portal\Http\Controllers\Customer;
|
|
|
|
use Modules\Portal\Http\Controllers\BasePortalController;
|
|
use Modules\Tms\Models\Shipment;
|
|
use Modules\Tms\Utils\TmsUtil;
|
|
|
|
class ShipmentController extends BasePortalController
|
|
{
|
|
public function __construct(protected TmsUtil $tmsUtil) {}
|
|
|
|
public function index()
|
|
{
|
|
$this->ensureCrmSubscription();
|
|
$statuses = $this->tmsUtil->shipmentStatuses();
|
|
$shipments = Shipment::where('business_id', $this->businessId())
|
|
->where('contact_id', $this->contactId())
|
|
->with(['driver:id,name', 'vehicle:id,plate_number', 'project:id,name'])
|
|
->orderByDesc('created_at')
|
|
->paginate(20);
|
|
|
|
return view('portal::customer.shipments.index', compact('shipments', 'statuses'));
|
|
}
|
|
|
|
public function show($id)
|
|
{
|
|
$this->ensureCrmSubscription();
|
|
$statuses = $this->tmsUtil->shipmentStatuses();
|
|
$shipment = Shipment::where('business_id', $this->businessId())
|
|
->where('contact_id', $this->contactId())
|
|
->with(['driver', 'vehicle', 'project', 'statusLogs'])
|
|
->findOrFail($id);
|
|
|
|
return view('portal::customer.shipments.show', compact('shipment', 'statuses'));
|
|
}
|
|
}
|