Commit 596c3ee3 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix receptionist 403 for super admins without branch_id

Super admins and academy owners aren't tied to a branch. Instead of
aborting, fall back to the first active branch so they can still
access the receptionist desk.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent d35573dd
......@@ -46,7 +46,7 @@ public function mount(): void
$this->branchId = $user->branch_id;
if (!$this->branchId) {
abort(403, __('يجب تعيينك لفرع لتحصيل المدفوعات'));
$this->branchId = \App\Domain\Identity\Models\Branch::where('is_active', true)->first()?->id;
}
}
......
......@@ -44,7 +44,7 @@ public function mount(): void
$this->branchId = $user->branch_id;
if (!$this->branchId) {
abort(403, __('يجب تعيينك لفرع لتسجيل المشتركين'));
$this->branchId = \App\Domain\Identity\Models\Branch::where('is_active', true)->first()?->id;
}
}
......
......@@ -56,7 +56,7 @@ public function mount(): void
$this->branchId = $user->branch_id;
if (!$this->branchId) {
abort(403, __('يجب تعيينك لفرع لتسجيل مشتركين جدد'));
$this->branchId = \App\Domain\Identity\Models\Branch::where('is_active', true)->first()?->id;
}
}
......
......@@ -26,11 +26,13 @@ public function mount(): void
$this->branchId = $user->branch_id;
if (!$this->branchId) {
// If user has no branch, they shouldn't use receptionist desk
abort(403, __('يجب تعيينك لفرع لاستخدام مكتب الاستقبال'));
$firstBranch = \App\Domain\Identity\Models\Branch::where('is_active', true)->first();
$this->branchId = $firstBranch?->id;
}
$this->branchName = $user->branch?->name_ar ?? '';
$this->branchName = $this->branchId
? (\App\Domain\Identity\Models\Branch::find($this->branchId)?->name_ar ?? '')
: '';
}
public function render()
......
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