/** * Display all User Accounts for this Crew */ public function accounts(Request $request, $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... $crew = Crew::findOrFail($id); $users = User::where('crew_id', $id)->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(); $request->session()->flash('active_menubutton', 'accounts'); // Tell the menubar which button to highlight return view('crews.accounts', ['crew' => $crew, 'users' => $users]); }
/** * Show the "Create New User" form. * * @return \Illuminate\Http\Response */ public function getRegister(Request $request, $id) { $crew = Crew::findOrFail($id); if (Auth::user()->cannot('actAsAdminForCrew', $crew)) { // The current user does not have permission to register a user for the specified crew return redirect()->back()->withErrors("You're not authorized to register users for that crew!"); } // Authorization complete - continue... $request->session()->flash('active_menubutton', 'accounts'); // Tell the menubar which button to highlight return view('auth.new_user')->with("crew_id", $id); }