Эх сурвалжийг харах

feat(support): adiciona validacao de suporte

ebagabee 3 долоо хоног өмнө
parent
commit
8484c56ffb

+ 4 - 3
app/Http/Controllers/SupportTicketController.php

@@ -20,9 +20,10 @@ public function index(): JsonResponse
             ->with(['applicantUnit', 'targetUnit'])
             ->orderBy('created_at', 'desc');
 
-        if (!$this->isMatriz($user)) {
-            $unitId = $user->units()->first()?->id;
-            $query->visibleToUnit($unitId);
+        if ($this->isMatriz($user)) {
+            $query->where(fn($q) => $q->where('origin', '!=', 'unit')->orWhere('scope', '!=', 'internal'));
+        } else {
+            $query->visibleToUnit($user->units()->first()?->id);
         }
 
         return $this->successResponse(