/** * Mark all new notifications as seen for the admin * * @return \Illuminate\Http\JsonResponse */ public function markAsSeen() { Notification::markAsSeen(); return $this->success(); }
/** * Mark all notifications as seen */ public static function markAsSeen() { if (Auth::admin()->check()) { $admin = Auth::admin()->get(); DB::table('notifications_seen')->where('admin_id', $admin->id)->delete(); $notificationIds = Notification::all()->lists('id')->toArray(); foreach ($notificationIds as $notificationId) { DB::table('notifications_seen')->insert(['notification_id' => $notificationId, 'admin_id' => $admin->id]); } } elseif (Auth::user()->check()) { $user = Auth::user()->get(); DB::table('notifications_seen')->where('user_id', $user->id)->delete(); $notificationIds = Notification::all()->lists('id')->toArray(); foreach ($notificationIds as $notificationId) { DB::table('notifications_seen')->insert(['notification_id' => $notificationId, 'user_id' => $user->id]); } } }
/** * Handle the event. * * @return void */ public function handle(ProductDeniedEvent $event) { $company = Company::where('nav_code', $event->navCode)->first(); $notification = Notification::createProductDenied($company, $event->orderNumber); $this->pusher->trigger('notification-channel', 'notification', json_encode($notification)); }