Download the PHP package timedoor/laravel-route-permission without Composer
On this page you can find all versions of the php package timedoor/laravel-route-permission. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download timedoor/laravel-route-permission
More information about timedoor/laravel-route-permission
Files in timedoor/laravel-route-permission
Package laravel-route-permission
Short Description Extented from spatie/laravel-permission, this package help developer to authorize user permission based from URI and request method.
License MIT
Informations about the package laravel-route-permission
Laravel Route Permission
Extended from spatie/laravel-permission version 5, this package help developer authorize user permission based on URI and request method.
Installation
Use the package manager composer to install this package.
Publish the package in your project with:
Then run the database migration.
Usage
You can use provided route middleware alias from this package named route-permission
that can be configured from config/permission.php
, for example:
Or if you using a guard you can use it like this, for example an api
guard.
Your user must be logged in if you use this middleware, this middleware will automatically match logged-in user permission with the current route URI.
For creating permission for REST API you can use provided permission model by this package, for example:
When saving the permission this package will trim all whitespace and /
character from provided uri
.
You can use *
as a wildcard character for route permissions.
Make sure you include the traits from Timedoor\RoutePermission
for role and permission models to use the extended features for the route.
For the uri
value use string provided from one of the below codes for accurate reference.
In the database, the permission name will be stored as route>>api/user>>*
(if the second parameter isn't provided it will be stored as a wildcard *
) or route>>api/user/{parameter}>>POST
(all route parameters will be converted to parameter
or you can change the behaviour from config/permission.php
)
You can access it with default spatie/laravel-permission
utility like:
Or using provided helper function to generate formatted permission name.
For manipulating route permission here's the list of other extended methods:
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.