46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Portal\Http\Controllers\Customer;
|
|
|
|
use Modules\Portal\Http\Controllers\BasePortalController;
|
|
use Modules\Portal\Services\CustomerMaintenanceScopeService;
|
|
|
|
class WorkOrderController extends BasePortalController
|
|
{
|
|
public function index()
|
|
{
|
|
$this->ensureCrmSubscription();
|
|
$scope = CustomerMaintenanceScopeService::forCurrentUser();
|
|
|
|
$workOrders = $scope->workOrderQuery()
|
|
->with(['equipment:id,name,code', 'assignedTechnician:id,first_name,last_name', 'project:id,name'])
|
|
->orderByDesc('created_at')
|
|
->paginate(20);
|
|
|
|
return view('portal::customer.work_orders.index', compact('workOrders'));
|
|
}
|
|
|
|
public function show($id)
|
|
{
|
|
$this->ensureCrmSubscription();
|
|
$scope = CustomerMaintenanceScopeService::forCurrentUser();
|
|
|
|
if (! $scope->ownsWorkOrder((int) $id)) {
|
|
abort(404);
|
|
}
|
|
|
|
$workOrder = $scope->workOrderQuery()
|
|
->with([
|
|
'equipment',
|
|
'project',
|
|
'productionLine',
|
|
'preventiveSchedule',
|
|
'assignedTechnician:id,first_name,last_name',
|
|
'requester:id,first_name,last_name',
|
|
])
|
|
->findOrFail($id);
|
|
|
|
return view('portal::customer.work_orders.show', compact('workOrder'));
|
|
}
|
|
}
|