|
@@ -71,9 +71,13 @@ public function replies()
|
|
|
public function scopeVisibleToUnit($query, int $unitId)
|
|
public function scopeVisibleToUnit($query, int $unitId)
|
|
|
{
|
|
{
|
|
|
return $query->where(function ($q) use ($unitId) {
|
|
return $query->where(function ($q) use ($unitId) {
|
|
|
|
|
+ // Cards created by this unit (origin = unit)
|
|
|
$q->where('unit_id', $unitId)
|
|
$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.
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|