middleware('auth'); } /** * Store the PushSubscription. * * @param Request $request * @return JsonResponse * @throws ValidationException */ public function store(Request $request){ $this->validate($request,[ 'endpoint' => 'required', 'keys.auth' => 'required', 'keys.p256dh' => 'required' ]); $endpoint = $request->endpoint; $token = $request->keys['auth']; $key = $request->keys['p256dh']; $user = Auth::user(); $user->updatePushSubscription($endpoint, $key, $token); return response()->json(['success' => true],200); } /** * Send Push Notifications to all users. * * @return RedirectResponse */ static public function push(){ \Illuminate\Support\Facades\Notification::send(User::all(), new PushNews); } }