Exemplo n.º 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit(Request $request, $id)
 {
     //
     if ($crew = Crew::findorfail($id)) {
         // Make sure this user is authorized...
         if (Auth::user()->cannot('actAsAdminForCrew', $id)) {
             // The current user does not have permission to perform admin functions for this crew
             return redirect()->back()->withErrors("You're not authorized to access that crew!");
         }
         // Authorization complete - continue...
         if (Auth::user()->isGlobalAdmin()) {
             $request->session()->flash('active_menubutton', 'crews');
             // Tell the menubar which button to highlight
         } else {
             $request->session()->flash('active_menubutton', 'identity');
             // Tell the menubar which button to highlight
         }
         // Decide whether to show the Aircraft section of the Edit Crew form:
         $show_aircraft = $crew->is_an_aircraft_crew();
         return view('crews.edit')->with('crew', $crew)->with('show_aircraft', $show_aircraft);
     }
     $errors = new MessageBag(['Crew' => ['That Crew doesn\'t exist.']]);
     //return redirect()->route('not_found')->withErrors($errors);
 }