嘿伙计们!我使用 Laravel 5.4,WAMP 作为本地主机。我正在努力解决Controller@methodName
在我的header.blade.php
文件中调用 a 的问题,因为我想在我的 header.blade.php 文件中显示用户的所有通知。通常,我在不同页面中的路线的帮助下获取所有需要的数据。但是对于这种情况,我需要在不使用路由的情况下调用。这是我的代码NotificationController
:
class NotificationController extends Controller
{
public function getNotification(){
$notifications = Notification::where('user_id',Auth::user()->id)->get();
$unread=0;
foreach($notifications as $notify){
if($notify->seen==0)$unread++;
}
return ['notifications'=>$notifications, 'unread'=>$unread];
}
}
我应该在我的头文件中接收所有这些数据。我用过: {{App::make("NotificationController")->getNotification()}}
和{{NotificationController::getNotification() }}但它说Class NotificationController does not exist
。请帮帮忙!