public function profile() { $user = User::findOrFail(Auth::user()->id); $userRoles = Helpers::getUserRoles(); return view('admin.pages.settings.profile', compact('user', 'userRoles')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // Use eager loading to pass address relation $user = User::with(['address', 'categories'])->findOrFail($id); $userRoles = Helpers::getUserRoles(); $userClubs = Helpers::getUserClubs(); $userCategories = Helpers::getUserCategories(); // Makes sure category checkboxes are correctly checked off // Assigns category id to collection index if (!$user->categories->isEmpty()) { foreach ($user['categories'] as $category) { $user['categories'][$category->id] = $category; } unset($user['categories'][0]); } return view('admin.pages.users.edit', compact('user', 'userCategories', 'userClubs', 'userRoles')); }