1 回答

TA貢獻1807條經驗 獲得超9個贊
您收到來自錯誤模型的通知。
根據您的代碼和數據庫結構,假設登錄用戶 id 為 3,employer_profile_user_id則為 12
$user->unreadNotifications從notifications表 where notifiable_typeisApp\User和notifiable_idis中獲取記錄3;
$user->employerProfile->unreadNotifications從notifications表 where notifiable_typeisApp\EmployerProfile和notifiable_idis中獲取記錄12;
所以試試這個計數
@if(Auth::user()->role_id === 2)
<!-- Counter - Alerts -->
<span class="badge badge-danger badge-counter">{{ Auth::user()->employerProfile->unreadNotifications->where('type', 'App\Notifications\SendJobSeekerResume')->count() }}</span>
@endif
這是細節
@if(Auth::user()->role_id === 2)
@foreach(Auth::user()->employerProfile->unreadNotifications as $notification)
<a class="dropdown-item d-flex align-items-center" href="#">
@include('layouts.partials.notification.'. Str::snake(class_basename($notification->type)))
</a>
@endforeach
@endif
- 1 回答
- 0 關注
- 98 瀏覽
添加回答
舉報