diff --git a/app/Http/Controllers/Repuve/PackageController.php b/app/Http/Controllers/Repuve/PackageController.php index d8da343..f431eed 100644 --- a/app/Http/Controllers/Repuve/PackageController.php +++ b/app/Http/Controllers/Repuve/PackageController.php @@ -31,6 +31,7 @@ public function index(Request $request) 'tags.status:id,code,name', 'tags.vehicle:id,placa,niv', 'tags.module:id,name', + 'tags.cancellationLogs.cancellationReason', 'user:id,name,email' ]); } else { @@ -107,6 +108,11 @@ public function index(Request $request) 'id' => $tag->module->id, 'name' => $tag->module->name, ] : null, + 'cancellation_reason' => in_array($tag->status?->code, ['cancelled', 'damaged']) && $tag->cancellationLogs->first() ? [ + 'reason' => $tag->cancellationLogs->first()->cancellationReason?->name, + 'observations' => $tag->cancellationLogs->first()->cancellation_observations, + 'cancelled_at' => $tag->cancellationLogs->first()->cancellation_at, + ] : null, ]; }), ];