use laratrust to replace entrust #78
This commit is contained in:
@@ -57,7 +57,6 @@ return [
|
||||
Prettus\Repository\Providers\RepositoryServiceProvider::class,
|
||||
InfyOm\Generator\InfyOmGeneratorServiceProvider::class,
|
||||
InfyOm\AdminLTETemplates\AdminLTETemplatesServiceProvider::class,
|
||||
Zizaco\Entrust\EntrustServiceProvider::class,
|
||||
Spatie\Fractal\FractalServiceProvider::class,
|
||||
SebastiaanLuca\Helpers\Methods\GlobalHelpersServiceProvider::class,
|
||||
SebastiaanLuca\Helpers\Collections\CollectionMacrosServiceProvider::class,
|
||||
@@ -86,7 +85,6 @@ return [
|
||||
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
||||
'DB' => Illuminate\Support\Facades\DB::class,
|
||||
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
||||
'Entrust' => Zizaco\Entrust\EntrustFacade::class,
|
||||
'Event' => Illuminate\Support\Facades\Event::class,
|
||||
'File' => Illuminate\Support\Facades\File::class,
|
||||
'Flash' => Laracasts\Flash\Flash::class,
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Entrust,
|
||||
* a role & permission management solution for Laravel.
|
||||
*
|
||||
* @license MIT
|
||||
* @package Zizaco\Entrust
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust Role Model
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the Role model used by Entrust to create correct relations. Update
|
||||
| the role if it is in a different namespace.
|
||||
|
|
||||
*/
|
||||
'role' => 'App\Models\Role',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust Roles Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the roles table used by Entrust to save roles to the database.
|
||||
|
|
||||
*/
|
||||
'roles_table' => 'roles',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust Permission Model
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the Permission model used by Entrust to create correct relations.
|
||||
| Update the permission if it is in a different namespace.
|
||||
|
|
||||
*/
|
||||
'permission' => 'App\Models\Permission',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust Permissions Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the permissions table used by Entrust to save permissions to the
|
||||
| database.
|
||||
|
|
||||
*/
|
||||
'permissions_table' => 'permissions',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust permission_role Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the permission_role table used by Entrust to save relationship
|
||||
| between permissions and roles to the database.
|
||||
|
|
||||
*/
|
||||
'permission_role_table' => 'permission_role',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust role_user Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the role_user table used by Entrust to save assigned roles to the
|
||||
| database.
|
||||
|
|
||||
*/
|
||||
'role_user_table' => 'role_user',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Foreign key on Entrust's role_user Table (Pivot)
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'user_foreign_key' => 'user_id',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Role Foreign key on Entrust's role_user Table (Pivot)
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'role_foreign_key' => 'role_id',
|
||||
|
||||
];
|
||||
210
config/laratrust.php
Normal file
210
config/laratrust.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Laratrust,
|
||||
* a role & permission management solution for Laravel.
|
||||
*
|
||||
* @license MIT
|
||||
* @package Laratrust
|
||||
*/
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Use MorphMap in relationships between models
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If true, the morphMap feature is going to be used. The array values that
|
||||
| are going to be used are the ones inside the 'user_models' array.
|
||||
|
|
||||
*/
|
||||
'use_morph_map' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Use cache in the package
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Defines if Laratrust will use Laravel's Cache to cache the roles and permissions.
|
||||
|
|
||||
*/
|
||||
'use_cache' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Use teams feature in the package
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Defines if Laratrust will use the teams feature.
|
||||
| Please check the docs to see what you need to do in case you have the package already configured.
|
||||
|
|
||||
*/
|
||||
'use_teams' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Strict check for roles/permissions inside teams
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Determines if a strict check should be done when checking if a role or permission
|
||||
| is attached inside a team.
|
||||
| If it's false, when checking a role/permission without specifying the team,
|
||||
| it will check only if the user has attached that role/permission ignoring the team.
|
||||
|
|
||||
*/
|
||||
'teams_strict_check' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust User Models
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the array that contains the information of the user models.
|
||||
| This information is used in the add-trait command, and for the roles and
|
||||
| permissions relationships with the possible user models.
|
||||
|
|
||||
| The key in the array is the name of the relationship inside the roles and permissions.
|
||||
|
|
||||
*/
|
||||
'user_models' => [
|
||||
'users' => 'App\Models\User',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Models
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These are the models used by Laratrust to define the roles, permissions and teams.
|
||||
| If you want the Laratrust models to be in a different namespace or
|
||||
| to have a different name, you can do it here.
|
||||
|
|
||||
*/
|
||||
'models' => [
|
||||
/**
|
||||
* Role model
|
||||
*/
|
||||
'role' => 'App\Models\Role',
|
||||
|
||||
/**
|
||||
* Permission model
|
||||
*/
|
||||
'permission' => 'App\Models\Permission',
|
||||
|
||||
/**
|
||||
* Team model
|
||||
*/
|
||||
'team' => 'App\Team',
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Tables
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These are the tables used by Laratrust to store all the authorization data.
|
||||
|
|
||||
*/
|
||||
'tables' => [
|
||||
/**
|
||||
* Roles table.
|
||||
*/
|
||||
'roles' => 'roles',
|
||||
|
||||
/**
|
||||
* Permissions table.
|
||||
*/
|
||||
'permissions' => 'permissions',
|
||||
|
||||
/**
|
||||
* Teams table.
|
||||
*/
|
||||
'teams' => 'teams',
|
||||
|
||||
/**
|
||||
* Role - User intermediate table.
|
||||
*/
|
||||
'role_user' => 'role_user',
|
||||
|
||||
/**
|
||||
* Permission - User intermediate table.
|
||||
*/
|
||||
'permission_user' => 'permission_user',
|
||||
|
||||
/**
|
||||
* Permission - Role intermediate table.
|
||||
*/
|
||||
'permission_role' => 'permission_role',
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Foreign Keys
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These are the foreign keys used by laratrust in the intermediate tables.
|
||||
|
|
||||
*/
|
||||
'foreign_keys' => [
|
||||
/**
|
||||
* User foreign key on Laratrust's role_user and permission_user tables.
|
||||
*/
|
||||
'user' => 'user_id',
|
||||
|
||||
/**
|
||||
* Role foreign key on Laratrust's role_user and permission_role tables.
|
||||
*/
|
||||
'role' => 'role_id',
|
||||
|
||||
/**
|
||||
* Role foreign key on Laratrust's permission_user and permission_role tables.
|
||||
*/
|
||||
'permission' => 'permission_id',
|
||||
|
||||
/**
|
||||
* Role foreign key on Laratrust's role_user and permission_user tables.
|
||||
*/
|
||||
'team' => 'team_id',
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This configuration helps to customize the Laratrust middleware behavior.
|
||||
|
|
||||
*/
|
||||
'middleware' => [
|
||||
/**
|
||||
* Define if the laratrust middleware are registered automatically in the service provider
|
||||
*/
|
||||
'register' => true,
|
||||
|
||||
/**
|
||||
* Method to be called in the middleware return case.
|
||||
* Available: abort|redirect
|
||||
*/
|
||||
'handling' => 'abort',
|
||||
|
||||
/**
|
||||
* Parameter passed to the middleware_handling method
|
||||
*/
|
||||
'params' => '403',
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Magic 'can' Method
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Supported cases for the magic can method (Refer to the docs).
|
||||
| Available: camel_case|snake_case|kebab_case
|
||||
|
|
||||
*/
|
||||
'magic_can_method_case' => 'kebab_case',
|
||||
];
|
||||
Reference in New Issue
Block a user