Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
48d62cfd
Commit
48d62cfd
authored
Sep 25, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding the permissions UI to the roles
parent
bb4d02ed
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
9 deletions
+39
-9
permissions.php
Config/permissions.php
+15
-0
users.php
Config/users.php
+0
-1
RolesController.php
Http/Controllers/Admin/RolesController.php
+11
-2
edit.blade.php
Resources/views/admin/roles/edit.blade.php
+13
-6
No files found.
Config/permissions.php
0 → 100644
View file @
48d62cfd
<?php
return
[
'users'
=>
[
'index'
,
'create'
,
'edit'
,
'delete'
],
'roles'
=>
[
'index'
,
'create'
,
'edit'
,
'delete'
],
];
\ No newline at end of file
Config/users.php
View file @
48d62cfd
<?php
return
[
];
\ No newline at end of file
Http/Controllers/Admin/RolesController.php
View file @
48d62cfd
...
...
@@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Redirect;
use
Illuminate\Support\Facades\View
;
use
Laracasts\Flash\Flash
;
use
Modules\Core\Http\Controllers\Admin\AdminBaseController
;
use
Modules\Core\Permissions\PermissionManager
;
use
Modules\User\Http\Requests\CreateRolesRequest
;
use
Modules\User\Http\Requests\UpdateRoleRequest
;
...
...
@@ -71,13 +72,16 @@ class RolesController extends AdminBaseController
* @param int $id
* @return Response
*/
public
function
edit
(
$id
)
public
function
edit
(
$id
,
PermissionManager
$manager
)
{
if
(
!
$role
=
$this
->
roles
->
find
(
$id
))
{
return
Redirect
::
to
(
'user::admin.roles.index'
);
}
return
View
::
make
(
'user::admin.roles.edit'
,
compact
(
'role'
));
// Get all permissions
$permissions
=
$manager
->
all
();
return
View
::
make
(
'user::admin.roles.edit'
,
compact
(
'role'
,
'permissions'
));
}
/**
...
...
@@ -89,9 +93,14 @@ class RolesController extends AdminBaseController
*/
public
function
update
(
$id
,
UpdateRoleRequest
$request
)
{
$roles
=
[];
foreach
(
$request
->
roles
as
$roleName
=>
$checkedRole
)
{
$roles
[
$roleName
]
=
(
bool
)
$checkedRole
;
}
$role
=
$this
->
roles
->
find
(
$id
);
$role
->
fill
(
$request
->
all
());
$role
->
permissions
=
$roles
;
$role
->
save
();
Flash
::
success
(
'Role updated!'
);
...
...
Resources/views/admin/roles/edit.blade.php
View file @
48d62cfd
...
...
@@ -54,12 +54,19 @@
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<?php
foreach
(
$role
->
permissions
as
$name
=>
$value
)
:
?>
<div
class=
"checkbox"
>
<label
for=
"perm1"
>
{{ $name }}
<input
id=
"perm1"
type=
"checkbox"
class=
"simple"
<?php
echo
$value
?
'checked'
:
''
?>
/>
</label>
</div>
<?php
foreach
(
$permissions
as
$name
=>
$value
)
:
?>
<h3>
{{ $name }} Module
</h3>
<?php
foreach
(
$value
as
$subRoleTitle
=>
$roleName
)
:
?>
<h4>
{{ $subRoleTitle }}
</h4>
<?php
foreach
(
$roleName
as
$rolePerm
)
:
?>
<div
class=
"checkbox"
>
<label
for=
"
<?php
echo
"
$subRoleTitle
.
$rolePerm
"
?>
"
>
{{ $rolePerm }}
<input
id=
"
<?php
echo
"
$subRoleTitle
.
$rolePerm
"
?>
"
name=
"roles[
<?php
echo
"
$subRoleTitle
.
$rolePerm
"
?>
]"
type=
"checkbox"
class=
"simple"
<?php
echo
$role
->
hasAccess
(
"
$subRoleTitle
.
$rolePerm
"
)
?
'checked'
:
''
?>
value=
"true"
/>
</label>
</div>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment