X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/0155525945bb030ae2265279dca8014c8cdcb2af..refs/pull/3118/head:/app/Http/Controllers/RoleController.php diff --git a/app/Http/Controllers/RoleController.php b/app/Http/Controllers/RoleController.php index 06a30e99d..7c72b5970 100644 --- a/app/Http/Controllers/RoleController.php +++ b/app/Http/Controllers/RoleController.php @@ -3,6 +3,7 @@ namespace BookStack\Http\Controllers; use BookStack\Auth\Permissions\PermissionsRepo; +use BookStack\Auth\Role; use BookStack\Exceptions\PermissionsException; use Exception; use Illuminate\Http\Request; @@ -23,7 +24,7 @@ class RoleController extends Controller /** * Show a listing of the roles in the system. */ - public function list() + public function index() { $this->checkPermission('user-roles-manage'); $roles = $this->permissionsRepo->getAllRoles(); @@ -34,11 +35,21 @@ class RoleController extends Controller /** * Show the form to create a new role. */ - public function create() + public function create(Request $request) { $this->checkPermission('user-roles-manage'); - return view('settings.roles.create'); + /** @var ?Role $role */ + $role = null; + if ($request->has('copy_from')) { + $role = Role::query()->find($request->get('copy_from')); + } + + if ($role) { + $role->display_name .= ' (' . trans('common.copy') . ')'; + } + + return view('settings.roles.create', ['role' => $role]); } /** @@ -48,8 +59,8 @@ class RoleController extends Controller { $this->checkPermission('user-roles-manage'); $this->validate($request, [ - 'display_name' => 'required|min:3|max:180', - 'description' => 'max:180', + 'display_name' => ['required', 'min:3', 'max:180'], + 'description' => ['max:180'], ]); $this->permissionsRepo->saveNewRole($request->all()); @@ -83,8 +94,8 @@ class RoleController extends Controller { $this->checkPermission('user-roles-manage'); $this->validate($request, [ - 'display_name' => 'required|min:3|max:180', - 'description' => 'max:180', + 'display_name' => ['required', 'min:3', 'max:180'], + 'description' => ['max:180'], ]); $this->permissionsRepo->updateRole($id, $request->all());