Jelajahi Sumber

feat(support): adiciona validacao de suporte

ebagabee 3 minggu lalu
induk
melakukan
8484c56ffb
1 mengubah file dengan 4 tambahan dan 3 penghapusan
  1. 4 3
      app/Http/Controllers/SupportTicketController.php

+ 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(