@auth @if(\App\Helpers\HelperTenant::isUserAllowedForTenant(Auth::user()->email) && \App\Helpers\HelperTenant::hasSelectedTenant())
@endif @endauth
{{-- ===== NOTIFICATION BELL ===== --}} @auth @php $unreadNotifs = collect(); $unreadCount = 0; try { if (\App\Helpers\HelperTenant::isUserAllowedForTenant(Auth::user()->email) && \App\Helpers\HelperTenant::hasSelectedTenant()) { $notifTenantConn = \App\Helpers\HelperTenant::getCurrentTenantConnection(); $notifTeacher = \App\Models\Teachers::on($notifTenantConn) ->where('email', Auth::user()->email) ->select('id') ->first(); $notifUser = \App\Models\User::on($notifTenantConn) ->where('email', Auth::user()->email) ->select('id') ->first(); if ($notifTeacher || $notifUser) { $notifQuery = \Illuminate\Notifications\DatabaseNotification::on($notifTenantConn) ->where(function ($q) use ($notifTeacher, $notifUser) { if ($notifTeacher) { $q->orWhere(function ($q2) use ($notifTeacher) { $q2->where('notifiable_type', \App\Models\Teachers::class) ->where('notifiable_id', $notifTeacher->id); }); } if ($notifUser) { $q->orWhere(function ($q2) use ($notifUser) { $q2->where('notifiable_type', \App\Models\User::class) ->where('notifiable_id', $notifUser->id); }); } }) ->whereNull('read_at'); $unreadCount = $notifQuery->count(); $unreadNotifs = $notifQuery->latest()->take(10)->get(); } } } catch (\Throwable $e) { // Không phá vỡ layout nếu có lỗi kết nối } @endphp
{{-- Nút chuông --}} {{-- Dropdown panel --}}
@endauth @auth @else @endauth
@auth @if(\App\Helpers\HelperTenant::isUserAllowedForTenant(Auth::user()->email) && \App\Helpers\HelperTenant::hasSelectedTenant()) @endif @endauth