/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $user = User::with('roles')->findOrFail($id); $data = array("id" => $user->id, "name" => $user->name, "availRoles" => Role::select('id', 'name')->orderBy('name')->lists('name', 'id'), "assignedRoles" => count($user->roles) > 0 ? $user->roles->lists('id') : 0); return view('larbac::users.edit-user', $data); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $role = Role::findOrFail($id); if ($role->delete()) { $perms = is_array(Request::get('permissions')) ? Request::get('permissions') : []; $role->permissions()->sync($perms); $role->users()->sync($perms); } return redirect(route(config('larbac.routes.routeRoles') . '.index')); }