[英]I am am developing a blog site in which when a writer write blog a notification send to admin in laravel
i am trying to develop an blogging site in which new blog activity show to admin when any writer write blog.我正在尝试开发一个博客网站,当任何作家写博客时,都会向管理员显示新的博客活动。 how can i take all notification of all blogger except auth user.
我如何接收除 auth 用户之外的所有博主的所有通知。 when user submit blog notification generated in notification table.
当用户提交通知表中生成的博客通知时。 below mention line fatch auth user data but i need all other user data except admin.
下面提到行 fatch auth 用户数据,但我需要除管理员之外的所有其他用户数据。 i use spatie for role and permission
我使用 spatie 作为角色和权限
@role('admin')
@foreach(auth()->user()->unreadnotifications as $notify)
<div class="dropdown-menu dropdown-menu-lg-right dropdown-secondary" aria-
labelledby="navbarDropdownMenuLink-5">
<a class="dropdown-item waves-effect waves-light" href="#"> {{$notify->data['message']}}<span
class="badge badge-danger ml-2">4</span></a>
</div>
@endforeach
@endrole
in your scenario you just take all the auth users notifications.That's why you will get only the current logged in users notifications.在您的场景中,您只需接收所有 auth 用户通知。这就是为什么您只会收到当前登录用户的通知。 you have to take all notifications except the admin like
您必须接受除管理员之外的所有通知,例如
$notifications = Notification::where('user_id','!=',1)->get();
and then in view, you can try like these然后在视图中,您可以尝试这些
@foreach($notifications as $notify)
<div class="dropdown-menu dropdown-menu-lg-right dropdown-secondary" aria-
labelledby="navbarDropdownMenuLink-5">
<a class="dropdown-item waves-effect waves-light" href="#"> {{$notify->data['message']}}<span
class="badge badge-danger ml-2">4</span></a>
</div>
@endforeach
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.