我會解釋我的想法。我希望當默認用戶做一個動作時,管理員會通知這個動作。爲此,我使用laravel中的通知保存在數據庫中(我不知道是否是更好的方法)。我的問題是,我無法顯示管理員用戶的通知。Laravel:當用戶做某事時通知管理員
我想,當一個用戶做一個具體的行動,所有的管理員將notifyed
$admins = Admin::all();<p>
foreach ($admins as $admin) {
<p>$admin->notify(new RepliedToThread($acao));<p>
}
接下來,我要顯示在導航欄的通知我的儀表板(僅管理員能夠訪問),做我做:
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Notificações <span class="badge"> {{Auth::admin()->unreadNotifications() }}</span>
</a>
<ul class="dropdown-menu" role="menu"><p>
<li>
@foreach (Auth::admin()->unreadNotifications as $notification)
{{$notification->type}}
@endforeach
</li>
</ul>
</li>
我不知道如果我這樣做的更好的方式,或者如果它會的工作,現在我有這樣的錯誤:
Method admin does not exist
但是我希望您對所有過程的幫助不僅僅是這個錯誤,因爲我不知道我是否以正確的方式進行。
what5 tou想到Pusher fotr我的目標是什麼? – Nuno
我對Pusher沒有任何經驗抱歉。正如我所說,我認爲事件可能是你正在嘗試做的一個很好的選擇。 – Loop77