public function saveRole() { $user_id = Input::get('user_id'); $role_id = Input::get('role_id'); $user = User::find($user_id); RoleUser::where('user_id', $user_id)->delete(); $user->attachRole($role_id); }
public function destroy($id) { $role = Role::find($id); $role_user = RoleUser::where('role_id', $id)->first(); if (is_null($role_user)) { $result = true; $content = '删除角色成功'; $role->delete(); } else { $result = false; $content = '删除角色失败,不能删除已经被用户关联的角色'; } $res = array('result' => $result, 'content' => $content); return $res; }