You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`markRolePermissions(string $roleName,arra $rolePermissions,string $permissionsSaveUrl = null)`: This method helps you to mark the stored role's permissions, you can define a url where you can store/update the permissions of the role
96
+
-`markRolePermissions(string $roleName,arra $rolePermissions,string $permissionsSaveUrl = null)`: This method helps you to mark the stored role's permissions in view so that you can identify which permissions are belongs to the role, you can define a url where you can store/update the permissions of the role
97
97
-`render()`: it render the view along with predefined data ($permissionCards, $permissionScripts), display these data in your blade. See the blade file example below
98
98
99
99
### Submiting permissions can be get by
@@ -179,6 +179,14 @@ class RoleController extends Controller
179
179
}
180
180
}
181
181
```
182
+
## Panel
183
+
Permissions could be generate for multiple panel, for example one application may have User panel and Admin panel, both may need different permissions. So we can achieve that by defining multiple panel, By default it is 'user' panel, assuming that all the permissions for user panel. But if you want different permissions for different panel you can generate that by defining another panel in the config.
@@ -187,94 +195,107 @@ Config the **config/permission-generator.php** file.
187
195
### 1. Splitter
188
196
If route name contains any special char then split the name by that char. It will use to generate permission text. For example if route name is **create.post** then permission text would be **Create Post**
189
197
```php
190
-
/**
191
-
* Split route name by defined needle
192
-
*/
193
198
'route-name-splitter-needle' => '.',
194
199
```
195
200
### 2. Custom Permissions
196
-
You can defined custom new permissions, add extra permissions to existing one.
201
+
You can defined custom new permissions, add extra permissions to existing one. You can add custom-permission for custom panel.
> Note: notice the `user-permission` key which contains only permission name, if no text key pass the package dynamically make a text for the permission name. You can also add extra permissions to exisiting permission, for example `bonus-permission` is an exisitng permission, we add custom `approve-own-department` extra permission to it.
> Note: notice the `user-permission` key which contains only permission name, if no **text** key pass the package dynamically make a **text** for the permission name. You can also add extra permissions to exisiting permission, for example `bonus-permission` is an exisitng permission, we add custom `approve-own-department` extra permission to it.
219
234
>
220
235
### 3. Permission Generate Controllers
221
-
From which controller's routes permission names will be generate, define it here. This config play vital role to generate permissions because permissions will be generated only for defined controllers.
236
+
This config play vital role to generate permissions because permissions will be generated only for defined controllers. Permission names will be generate, from only defined controller's route names. By Default permission names will be generated from all controller's routes for user panel. You can define custom panel and it's permission generate controllers.
237
+
**Controller could be fully qualified class name or namespace-prefix.**
222
238
223
239
```php
224
-
/**
225
-
* Permission generate controller's namespace
226
-
*
227
-
* By Default permission names will be generated from all controller's routes
Exclude routes by defining controller namespace. Here auth and EmployeeProfileController related routes will be excluded from being generated as permission names.
240
-
257
+
Exclude routes by controller. By default all auth controller's routes will be excluded from being generated as permission names for user panel.
258
+
**Controller could be fully qualified class name or namespace-prefix.**
241
259
```php
242
-
/**
243
-
* Exclude routes by controller's namespace
244
-
*/
245
260
'exclude-controllers' => [
246
-
'App\Http\Controllers\Auth', // exclude routes of all auth controllers
247
-
248
-
// sample
249
-
App\Http\Controller\Employee\EmployeeProfileController::class, // exclude routes of EmployeeProfileController
261
+
'panels' => [
262
+
'user' => [
263
+
'App\Http\Controllers\Auth', // exclude routes of all auth controllers
Copy file name to clipboardExpand all lines: config/permission-generator.php
+58-13Lines changed: 58 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,12 @@
1
1
<?php
2
-
3
-
2
+
/**
3
+
* In an application we may have permissions like 'create-post', 'edit-post', and these permission are hardcoded. Using the package
4
+
* We can dynamically generate these permissions from route names or defining resource name
5
+
*
6
+
* Note: permissions could be generate for multiple panel, for example one application may have User panel and Admin panel, both may need different permissions
7
+
* So we can achieve that by defining multiple panel, By default it is 'user' panel, assuming that all the permissions for user panel.
8
+
* If you want different permissions for different panel you can generate that by defining another panel.
9
+
*/
4
10
return [
5
11
/**
6
12
* Split route name by defined needle
@@ -9,36 +15,68 @@
9
15
10
16
/**
11
17
* Custom permissions
18
+
*
19
+
* Here you can add custom permissions for individual panel, you can add multiple panel ex: admin panel
12
20
*/
13
21
'custom-permissions' => [
14
-
22
+
'panels' => [
23
+
'user' => [
24
+
// custom-permissions
25
+
],
26
+
// 'admin' => [
27
+
// // custom-permission
28
+
//],
29
+
]
15
30
],
16
31
17
32
/**
18
-
* Permission generate controller's namespace
33
+
* Permission generate controller's
19
34
*
20
-
* By Default permissions will be generated from all controller's routes
35
+
* By Default permissions will be generated from all controller's routes for user panel
21
36
*/
22
37
'permission-generate-controllers' => [
23
-
'App\Http\Controllers',
38
+
'panels' => [
39
+
'user' => [
40
+
'App\Http\Controllers',
41
+
],
42
+
// 'admin' => [
43
+
// 'App\Http\Controllers\Admin',
44
+
//],
45
+
]
24
46
],
25
47
26
48
/**
27
-
* Exclude routes by controller's namespace
49
+
* Exclude routes by controller's
28
50
*
29
-
* By default all auth controller's routes will be excluded from being generated as permission names
51
+
* By default all auth controller's routes will be excluded from being generated as permission names for user panel
30
52
*
31
-
* [Note: Exclude routes by defining App\Http\Controller\SomeController::class or namespace-prefix]
53
+
* [Note: routes can be excluded by defining App\Http\Controller\SomeController::class or namespace-prefix 'App\Http\Controllers\Auth']
32
54
*/
33
55
'exclude-controllers' => [
34
-
'App\Http\Controllers\Auth',
56
+
'panels' => [
57
+
'user' => [
58
+
'App\Http\Controllers\Auth',
59
+
],
60
+
// 'admin' => [
61
+
// 'App\Http\Controllers\Admin\Auth',
62
+
//],
63
+
]
35
64
],
36
65
37
66
/**
38
67
* Exclude routes by route name
68
+
*
69
+
* Panel wise you can exclude routes
39
70
*/
40
71
'exclude-routes' => [
41
-
// route.name
72
+
'panels' => [
73
+
'user' => [
74
+
// route.name,
75
+
],
76
+
// 'admin' => [
77
+
// // route.name,
78
+
//],
79
+
]
42
80
],
43
81
44
82
/**
@@ -64,7 +102,7 @@
64
102
],
65
103
66
104
/**
67
-
* Parmissions can be organised by section (ex: adminland, settings, employee managment etc)
105
+
* Parmissions can be grouped by section (ex: adminland, settings, employee managment etc)
68
106
*
69
107
* sample format: key as section name, value as generated permissions-title
0 commit comments