Download the PHP package distilleries/permission-util without Composer
On this page you can find all versions of the php package distilleries/permission-util. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download distilleries/permission-util
More information about distilleries/permission-util
Files in distilleries/permission-util
Package permission-util
Short Description Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403
License MIT
Informations about the package permission-util
Laravel 5 Permission Util
Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403
Table of contents
- Installation
- Basic usage
- Middleware
Installation
Add on your composer.json
run composer update
.
Add Service provider to config/app.php
:
And Facade (also in config/app.php
)
Export the configuration:
Basic usage
To check the permission, I use the auth
of your application.
On your model use for the Auth implement the interface Distilleries\PermissionUtil\Contracts\PermissionUtilContract
add the method hasAccess
to define if the user have access or not.
The key in param is a string action like UserController@getEdit
.
If the user is connected and your model haven't this method the class return true.
If the user is not connected the permission util return false.
To disabled the restriction of connected user just go in config file and put false in auth_restricted
.
You can use the facade to detect if the user can access or not:
Method | Call | Description |
---|---|---|
hasAccess |
PermissionUtil::hasAccess('Controller@action') |
Return if the user can access to this action |
Middleware
The package provide a middleware to detect automatically if the user can access to a method of a controller.
To active it just add on your app/Http/Kernel
:
And on your controller or your route add the middleware:
If the user can access to an action that dispatch a 403
All versions of permission-util with dependencies
illuminate/support Version 5.8.*|^6.0
illuminate/session Version 5.8.*|^6.0
illuminate/http Version 5.8.*|^6.0