Download the PHP package denismitr/laravel-permissions without Composer
On this page you can find all versions of the php package denismitr/laravel-permissions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-permissions
Version 2.1
Laravel Permissions
This is a package to integrate with Laravel 5.5 - 5.8
Installation
Require this package with composer:
After updating composer, add the PermissionsServiceProvider
to the providers array in config/app.php
like so:
Then if you need to use one of the provided middleware, you can add a auth.group
middleware to your Http Kernel.php
like so:
This one insures that user belongs to all required auth groups
Publish config and migrations
and pick Provider: Denismitr\Permissions\PermissionsServiceProvider
from the list
Migration
Then run php artisan migrate
and the following 5 tables will be created:
- auth_groups
- permissions
- auth_group_users
- auth_group_permissions
Creating the CRUD and populating these tables is up to you.
Usage
First include InteractsWithAuthGroups
trait into the User
model like so:
To add users to an AuthGroup and give them group permissions:
Check if auth group already exists
Private groups and/or teams
User can create private groups or basically teams. Note that there is a canOwnAuthGroups
method on
InteractsWithAuthGroups
trait that returns true
by default. If you want to define some custom rules on
whether this or that user is allowed to create auth groups, which you probably do, you need to
override that method in your user model.
Roles
roles are just strings and they are supposed to be used just as additional helpers.
To withdraw permissions
Grant permission through auth group:
To check for permissions:
Attention!!! for compatibility reasons the method can support only single ability argument
Current AuthGroup
User can have a current auth group, via a current_auth_group_id
column that is being added to the users
table by the package migrations. This feature can be used to emulate switching between teams for example.
Note that in case user belongs to one or more auth groups the currentAuthGroup()
method will automatically choose and set one of the users auth group as current, persist it on User
model via current_auth_group_id
column and return it. The same applies to currentAuthGroupName()
.
Plus a bonus a blade authgroup
and team
directives:
And it's alias
Some other directives
Author
Denis Mitrofanov
All versions of laravel-permissions with dependencies
illuminate/console Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0
illuminate/database Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0
illuminate/auth Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0
illuminate/container Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0
illuminate/contracts Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0
illuminate/events Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0
illuminate/support Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0