public function deleteIndex() { // Delete user $id $id = \Request::input('user_id'); $user = User::find($id); $user->groups()->sync([]); $user->delete(); return redirect('/admin/users'); }
public function addUserToGroup($groupId) { $group = Group::find($groupId); $group->users()->attach(\Request::input('user')); /* Ajax code added in controller, but not in Javascript. Debating whether it is appropriate to use Ajax in this case. */ if (\Request::ajax()) { $user = User::find(input('user')); return \Response::json(array('status' => 'ok', 'user' => array('id' => $user->id, 'charname' => $user->char_name, 'email' => $user->email))); } return redirect('/admin/groups/' . $groupId); }