public function edit($userId)
 {
     $user = User::with('roles')->findOrFail($userId);
     $userRoleIds = $user->roles->modelKeys();
     $roles = Role::whereNotIn('id', $userRoleIds)->get();
     return view('admin.user.edit', ['user' => $user, 'roles' => $roles]);
 }
Beispiel #2
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($userId)
 {
     //
     $user = User::findOrFail($userId);
     $roleIds = Userrole::where('user_id', $userId)->select('role_id')->get();
     $roleList = Role::whereNotIn('id', $roleIds)->select('id', DB::raw('concat(name, \' - \', display_name) as name'))->lists('name', 'id');
     if ($user != null) {
         return view('system.userroles.create', compact('user', 'roleList'));
     } else {
         return '无此用户';
     }
 }