app/Providers/AuthServiceProvider.php
/**
     * Register any authentication / authorization services.
     *
     * @return void
     */
Register any authentication / authorization services.
@return void
Register any authentication / authorization services . @return void
public function boot()
    {
        $this->registerPolicies();
        $user = \Auth::user();
        Gate::define('user_management_access', function ($user) {
            return in_array($user->role_id, [1, 2]);
        });
        Gate::define('role_access', function ($user) {
            return in_array($user->role_id, [1, 2]);
        });
        Gate::define('role_create', function ($user) {
            return in_array($user->role_id, [1, 2]);
        });
        Gate::define('role_edit', function ($user) {
            return in_array($user->role_id, [1, 2]);
        });
        Gate::define('role_view', function ($user) {
            return in_array($user->role_id, [1, 2]);
        });
        Gate::define('role_delete', function ($user) {
            return in_array($user->role_id, [1]);
        });
        Gate::define('user_access', function ($user) {
            return in_array($user->role_id, [1]);
        });
        Gate::define('user_create', function ($user) {
            return in_array($user->role_id, [1]);
        });
        Gate::define('user_edit', function ($user) {
            return in_array($user->role_id, [1]);
        });
        Gate::define('user_view', function ($user) {
            return in_array($user->role_id, [1]);
        });
        Gate::define('user_delete', function ($user) {
            return in_array($user->role_id, [1]);
        });
        Gate::define('user_action_access', function ($user) {
            return in_array($user->role_id, [1, 2]);
        });
        Gate::define('view_field_access', function ($user) {
            return in_array($user->role_id, [1]);
        });
        Gate::define('view_field_create', function ($user) {
            return in_array($user->role_id, [1, 3, 4, 5]);
        });
        Gate::define('view_field_edit', function ($user) {
            return in_array($user->role_id, [1, 3, 4, 5]);
        });
        Gate::define('view_field_view', function ($user) {
            return in_array($user->role_id, [1, 3, 4, 5]);
        });
        Gate::define('view_field_delete', function ($user) {
            return in_array($user->role_id, [1]);
        });
    }
public function boot ( ) { $ this -> registerPolicies ( ) ; $ user = \ Auth :: user ( ) ; Gate :: define ( 'user_management_access' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 , 2 ] ) ; } ) ; Gate :: define ( 'role_access' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 , 2 ] ) ; } ) ; Gate :: define ( 'role_create' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 , 2 ] ) ; } ) ; Gate :: define ( 'role_edit' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 , 2 ] ) ; } ) ; Gate :: define ( 'role_view' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 , 2 ] ) ; } ) ; Gate :: define ( 'role_delete' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 ] ) ; } ) ; Gate :: define ( 'user_access' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 ] ) ; } ) ; Gate :: define ( 'user_create' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 ] ) ; } ) ; Gate :: define ( 'user_edit' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 ] ) ; } ) ; Gate :: define ( 'user_view' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 ] ) ; } ) ; Gate :: define ( 'user_delete' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 ] ) ; } ) ; Gate :: define ( 'user_action_access' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 , 2 ] ) ; } ) ; Gate :: define ( 'view_field_access' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 ] ) ; } ) ; Gate :: define ( 'view_field_create' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 , 3 , 4 , 5 ] ) ; } ) ; Gate :: define ( 'view_field_edit' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 , 3 , 4 , 5 ] ) ; } ) ; Gate :: define ( 'view_field_view' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 , 3 , 4 , 5 ] ) ; } ) ; Gate :: define ( 'view_field_delete' , function ( $ user ) { return in_array ( $ user -> role_id , [ 1 ] ) ; } ) ; }
Register any authentication / authorization services.
Register any authentication / authorization services .
// Auth gates for: User management // Auth gates for: Roles // Auth gates for: Users // Auth gates for: User actions // Auth gates for: View fields