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
Copy file name to clipboardExpand all lines: README.md
+74-67Lines changed: 74 additions & 67 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,41 +1,43 @@
1
-
# Laravel Route Permission
1
+
# Laravel Permission Name Generator
2
2
[](https://packagist.org/packages/radiatecode/laravel-route-permission)
In role-permission base authorization we generally add permissions to a db table, then assign the permissions to a user or a role.
6
-
This package will generate permissions from route names, so no need for a permission db table. we can assign these permissions to a user, or a particular role
7
-
to authorize user actions. There is a pre-built generator to generate role base permission view.
5
+
This package will generate permission names from route names. Permissions are grouped by controller name. These permission names can be usefull for authorization (role-permission base system)
While this package generate permission names from route names, in some cases we might need to exclude some permission names. To do so implement the **WithPermissionGenerator** contracts in the controller, then use the **PermissionGenerator** trait. We can use `permissionExcludeMethods()` to exclude permissions by route associative method. We can also define permission group name `permissionGroupTitle()`.
79
+
80
+
```php
81
+
use App\Http\Controllers\Controller;
82
+
use RadiateCode\LaravelRoutePermission\Contracts\WithPermissionGenerator;
83
+
use RadiateCode\LaravelRoutePermission\Traits\PermissionGenerator;
84
+
85
+
class OfficeController extends Controller implements WithPermissionGenerator
->permissionExcludeMethods('index','listDatatable'); // when necessary exclude specific routes by the controller methods
93
+
}
94
+
}
95
+
```
96
+
97
+
> **PermissionGenerator** trait is optional. Because if no permissible title defined, then this package dynamically generate a title based on controller name, And routes/permissions can be excluded in the config file.
98
+
99
+
## Get Permissions
100
+
101
+
You can get permissible routes And make your own permissions view in order to set role permissions.
> Under the hood it gets all the routes which registered in **web.php** and only take those routes which has permission middleware. The permissible routes grouped by controller.
110
+
111
+
## Permission View Builder Facade
112
+
If you don't want to make permission view by your own, then you can use predefined permissions view [**PermissionViewBuilder** facade].
113
+
114
+
See the above [example](#example)
115
+
116
+
**Builder methods:**
117
+
118
+
- permissionView() : generate bootstrap permissions card based on permissible routes, and config defined action buttons.
119
+
- withRolePermissions($roleName,$rolePermissions) : it is used to select all the permissions that have access to a particular role.
120
+
- permissionScripts($url = null) : generate functions for check all and uncheck all buttons. The **$url** param used to submit the selected permissions for specific role.
121
+
122
+
> **Note:** When submit the permissions from predefined view to any post routes you need to get the permissions by
123
+
> ```php
124
+
> $request->get('permissions'); // array of permissions
Controller basis we can define permission title, exclude routes by methods. First implement the **WithPermissible**
151
-
Interface in a controller, then use the **Permissible** trait.
152
-
153
-
```php
154
-
use App\Http\Controllers\Controller;
155
-
use RadiateCode\LaravelRoutePermission\Contracts\WithPermissionGenerator;
156
-
use RadiateCode\LaravelRoutePermission\Traits\PermissionGenerator;
157
-
158
-
class OfficeController extends Controller implements WithPermissionGenerator
159
-
{
160
-
use PermissionGenerator;
161
-
162
-
public function __construct()
163
-
{
164
-
$this->permissibleTitle('Office Crud Permission')
165
-
->permissionExcludeMethods('index','listDatatable'); // when necessary exclude specific routes by the controller methods
166
-
}
167
-
}
168
-
```
169
-
170
-
> Permissible trait is optional. Because if no permissible title defined, then this package dynamically generate a title based on controller name, And routes can be excluded in the config file.
171
-
172
-
## Permissible routes
173
-
174
-
You can get permissible routes And make your own permissions view in order to set role permissions.
> Under the hood it gets all the routes which registered in **web.php** and only take those routes which has permission middleware. The permissible routes grouped by controller.
183
-
184
-
## Permission View Builder Facade
185
-
If you don't want to make permission view by your own, then you can use predefined permissions view [**PermissionViewBuilder** facade].
186
-
187
-
See the above [example](#example)
188
-
189
-
**Builder methods:**
190
-
191
-
- permissionView() : generate bootstrap permissions card based on permissible routes, and config defined action buttons.
192
-
- withRolePermissions($roleName,$rolePermissions) : it is used to select all the permissions that have access to a particular role.
193
-
- permissionScripts($url = null) : generate functions for check all and uncheck all buttons. The **$url** param used to submit the selected permissions for specific role.
194
-
195
-
> **Note:** When submit the permissions from predefined view to any post routes you need to get the permissions by
196
-
> ```php
197
-
> $request->get('permissions'); // array of permissions
198
-
> ```
199
-
200
207
## Contributing
201
208
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
0 commit comments