1 回答

TA貢獻1807條經(jīng)驗 獲得超9個贊
您收到來自錯誤模型的通知。
根據(jù)您的代碼和數(shù)據(jù)庫結(jié)構(gòu),假設(shè)登錄用戶 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;
所以試試這個計數(shù)
@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
這是細節(jié)
@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 關(guān)注
- 106 瀏覽
添加回答
舉報