SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function requestatc_send(Request $request) {
  2.         $validatedate = $request->validate([ //checks are following inputs empty
  3.  
  4.             'event_name' => 'required', //checking is event_name input empty
  5.  
  6.             'route' => 'required', //checking is route input empty
  7.  
  8.             'dep' => 'required', //checking is departure input empty
  9.  
  10.             'arr' => 'required', //checking is arrivals input empty
  11.  
  12.             'positions' => 'required' //checking is positions input empty
  13.  
  14.         ]);
  15.             $id = str_random(10);
  16.         RequestATC::create([
  17.             'request_id' => $id,
  18.             'user_id' => Auth::user()->id,
  19.             'user_name' => Auth::user()->fname . Auth::user()->lname,
  20.             'user_email' => Auth::user()->email,
  21.             'event_name' => $request->get('event_name'),
  22.             'sponsors' => $request->get('va_name'),
  23.             'event_website' => $request->get('website'),
  24.             'dep_airport' => $request->get('dep'),
  25.             'arr_airport' => $request->get('arr'),
  26.             'route' => $request->get('route'),
  27.             'positions' => $request->get('positions'),
  28.             'num_of_pilots' => $request->get('number_pilots'),
  29.             'comments' => $request->get('comments'),
  30.         ]);
  31.  
  32.         $sendData = RequestATC::where('request_id', $id)->firstOrFail();
  33.  
  34.         $user = User::where('id', Auth::user()->id)->first();
  35.         event(new NewATCRequestEvent($user));
  36.  
  37.         $notification = Notification::where('notifiable_id', Auth::user()->id)->orderBy('created_at', 'desc')->first();
  38.         Notification::updateOrCreate([
  39.             'id' => $notification->id,
  40.             $notification->title => 'Thank You for sending an ATC request! Staff will take a look on it as soon as possible.'
  41.         ], [
  42.             $notification->text = 'New ATC Request Created!',
  43.  
  44.         ]);
  45.  
  46.         $users = User::where('staff_level', '>=', 2)->get();
  47.         foreach ($users as $user) {
  48.             event(new NewATCRequestEvent($user));
  49.             $notification = Notification::where('notifiable_id', $user->id)->orderBy('created_at', 'desc')->first();
  50.             $notification->text = 'New ATC Request!';
  51.             $notification->title = '<a href="/staff/requests#' . $sendData->request_id . '">Take a look</a>';
  52.             $notification->save();
  53.         }
  54.             return redirect()->back()->withSuccess('ATC Request Successfully sent!'); //redirecting back
  55.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top