/** * Bootstrap any application services. * * @return void */ public function boot() { view()->composer('layouts.master', function ($view) { $notification_obj = Notification::read(Auth::user()->id, true, 3); $notification_list = Notification::format($notification_obj); $view->with('user_notification_count', Notification::count(Auth::user()->id)); $view->with('user_notification_list', $notification_list); $view->with('user_messages_count', Messages::countUnseen()); $view->with('user_messages_list', Messages::topUnseen(3)); }); view()->composer('users.list', function ($view) { $view->with('company_id', User::where('id', Auth::user()->id)->with(['company' => function ($q) { $q->select('companies.id', 'companies.name'); }])->first()->company->pluck('id')->toArray()[0] ?? ""); $view->with('company_name', User::where('id', Auth::user()->id)->with(['company' => function ($q) { $q->select('companies.id', 'companies.name'); }])->first()->company->pluck('name')->toArray()[0] ?? ""); }); }
public function showAllNotifications($id = null) { if ($id == null) { $id = Auth::user()->id; } $notification_count = Notification::count($id); $notification_obj = Notification::read($id, false, 1000, 12); $notifications = Notification::format($notification_obj); $user = User::with('info')->where('id', $id)->first(); return view('users.notifications')->with(['notifications' => $notifications, 'notifications_obj' => $notification_obj, 'notification_count' => $notification_count, 'user' => $user]); }