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 关注
- 127 浏览
添加回答
举报
