Commit a6c8abb9 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix program list: show academy-wide programs (null branch_id) alongside branch programs

Programs with branch_id=NULL are academy-wide — they should be visible
regardless of which branch is selected. The filter now uses
WHERE branch_id = X OR branch_id IS NULL.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent bf0a7839
...@@ -78,7 +78,9 @@ public function render() ...@@ -78,7 +78,9 @@ public function render()
$query = TrainingProgram::query() $query = TrainingProgram::query()
->with(['activity', 'branch']) ->with(['activity', 'branch'])
->withCount('groups') ->withCount('groups')
->when($branchId, fn ($q) => $q->where('branch_id', $branchId)) ->when($branchId, fn ($q) => $q->where(function ($sub) use ($branchId) {
$sub->where('branch_id', $branchId)->orWhereNull('branch_id');
}))
->when($this->search, fn ($q) => $q->where(function ($sub) { ->when($this->search, fn ($q) => $q->where(function ($sub) {
$sub->where('name_ar', 'ilike', "%{$this->search}%") $sub->where('name_ar', 'ilike', "%{$this->search}%")
->orWhere('name', 'ilike', "%{$this->search}%"); ->orWhere('name', 'ilike', "%{$this->search}%");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment