public function defineAllPermissions()
    {
        foreach ($this->getPermissions() as $permission) {

            Gate::define(
                $permission->name,
                function ($user, ...$arguments) use ($permission) {
                    foreach ($permission->roles as $role) {
                        if ($role->belongsToUser($user)) {
                            if (!empty($permission->class)
                                AND !empty($permission->method)
                                AND class_exists($permission->class)
                            ) {
                                $container = resolve($permission->class);
                                if (method_exists($container, $permission->method)) {
                                    array_unshift($arguments, $user);
                                    return
                                        call_user_func_array(
                                            [$container, $permission->method],
                                            $arguments
                                        );
                                } else {
                                    return false;
                                }
                            }
                            return true;
                        }
                    }
                    return false;
                }
            );
        }
        return false;
    }
public function defineAllPermissions()
    {
        foreach ($this->getPermissions() as $permission) {

            Gate::define(
                $permission->name,
                function ($user, ...$arguments) use ($permission) {
                    foreach ($permission->roles as $role) {
                        if ($role->belongsToUser($user)) {
                            if (!empty($permission->class)
                                AND !empty($permission->method)
                                AND class_exists($permission->class)
                            ) {
                                $container = resolve($permission->class);
                                if (method_exists($container, $permission->method)) {
                                    array_unshift($arguments, $user);
                                    return
                                        call_user_func_array(
                                            [$container, $permission->method],
                                            $arguments
                                        );
                                } else {
                                    return false;
                                }
                            }
                            return true;
                        }
                    }
                    return false;
                }
            );
        }
        return false;
    }
public function defineAllPermissions ( ) { foreach ( $ this -> getPermissions ( ) as $ permission ) { Gate :: define ( $ permission -> name , function ( $ user , ... $ arguments ) use ( $ permission ) { foreach ( $ permission -> roles as $ role ) { if ( $ role -> belongsToUser ( $ user ) ) { if ( ! empty ( $ permission -> class ) AND ! empty ( $ permission -> method ) AND class_exists ( $ permission -> class ) ) { $ container = resolve ( $ permission -> class ) ; if ( method_exists ( $ container , $ permission -> method ) ) { array_unshift ( $ arguments , $ user ) ; return call_user_func_array ( [ $ container , $ permission -> method ] , $ arguments ) ; } else { return false ; } } return true ; } } return false ; } ) ; } return false ; }
Define all permission and make usable from laravel application

@return bool
Define all permission and make usable from laravel application