Przeglądaj źródła

fix(kanban): remove orWhere(scope, all) from visibleToUnit scope

Broadcasting already creates one card per unit with a specific
target_unit_id. The orWhere('scope', 'all') was causing every
broadcast card to appear in every unit's board — e.g. a card
targeted at Maceió was also showing for Atalaia.
ebagabee 2 tygodni temu
rodzic
commit
4b019288c7
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      app/Models/Kanban.php

+ 6 - 2
app/Models/Kanban.php

@@ -71,9 +71,13 @@ public function replies()
     public function scopeVisibleToUnit($query, int $unitId)
     {
         return $query->where(function ($q) use ($unitId) {
+            // Cards created by this unit (origin = unit)
             $q->where('unit_id', $unitId)
-              ->orWhere('target_unit_id', $unitId)
-              ->orWhere('scope', 'all');
+              // Cards explicitly targeted at this unit (specific or broadcast-per-unit)
+              ->orWhere('target_unit_id', $unitId);
+            // Note: scope='all' is NOT used here — when broadcasting the controller
+            // already creates one card per unit each with its own target_unit_id,
+            // so filtering by target_unit_id is sufficient and correct.
         });
     }
 }