classes/Models/Admin.php
public static function getPermissionOptions($admin = null)
    {
        // Get all the app controllers
        $controllers = array_map(function($path) {
            return 'App\Http\Controllers\Admin\\'.basename($path, '.php');
        }, glob(app_path('/Http/Controllers/Admin/*.php')));

        // Add some Decoy controllers
        $controllers[] = 'Bkwld\Decoy\Controllers\Admins';
        $controllers[] = 'Bkwld\Decoy\Controllers\Changes';
        $controllers[] = 'Bkwld\Decoy\Controllers\Elements';
        $controllers[] = 'Bkwld\Decoy\Controllers\RedirectRules';

        // Alphabetize the controller classes
        usort($controllers, function ($a, $b) {
            return substr($a, strrpos($a, '\\') + 1) > substr($b, strrpos($b, '\\') + 1);
        });

        // Convert the list of controller classes into the shorthand strings used
        // by Decoy Auth as well as english name and desciption
        return array_map(function ($class) use ($admin) {
            $obj = new $class;
            $permissions = $obj->getPermissionOptions();
            if (!is_array($permissions)) {
                $permissions = [];
            }

            // Build the controller-level node
            return (object) [

                // Add controller information
                'slug' => DecoyURL::slugController($class),
                'title' => $obj->title(),
                'description' => $obj->description(),

                // Add permission options for the controller
                'permissions' => array_map(function ($value, $action) use ($class, $admin) {
                    $roles = array_keys(Config::get('decoy.site.roles'));

                    return (object) [
                        'slug' => $action,
                        'title' => is_array($value) ? $value[0] : Text::titleFromKey($action),
                        'description' => is_array($value) ? $value[1] : $value,

                        // Set the initial checked state based on the admin's permissions, if
                        // one is set.  Or based on the first role.
                        'checked' => $admin ?
                            $admin->can($action, $class) :
                            with(new Admin(['role' => $roles[0]]))->can($action, $class),

                        // Filter the list of roles to just the roles that allow the
                        // permission currently being iterated through
                        'roles' => array_filter($roles, function ($role) use ($action, $class) {
                            return with(new Admin(['role' => $role]))->can($action, $class);
                        }),

                    ];
                }, $permissions, array_keys($permissions)),
            ];
        }, $controllers);
    }
public static function getPermissionOptions($admin = null)
    {
        // Get all the app controllers
        $controllers = array_map(function($path) {
            return 'App\Http\Controllers\Admin\\'.basename($path, '.php');
        }, glob(app_path('/Http/Controllers/Admin/*.php')));

        // Add some Decoy controllers
        $controllers[] = 'Bkwld\Decoy\Controllers\Admins';
        $controllers[] = 'Bkwld\Decoy\Controllers\Changes';
        $controllers[] = 'Bkwld\Decoy\Controllers\Elements';
        $controllers[] = 'Bkwld\Decoy\Controllers\RedirectRules';

        // Alphabetize the controller classes
        usort($controllers, function ($a, $b) {
            return substr($a, strrpos($a, '\\') + 1) > substr($b, strrpos($b, '\\') + 1);
        });

        // Convert the list of controller classes into the shorthand strings used
        // by Decoy Auth as well as english name and desciption
        return array_map(function ($class) use ($admin) {
            $obj = new $class;
            $permissions = $obj->getPermissionOptions();
            if (!is_array($permissions)) {
                $permissions = [];
            }

            // Build the controller-level node
            return (object) [

                // Add controller information
                'slug' => DecoyURL::slugController($class),
                'title' => $obj->title(),
                'description' => $obj->description(),

                // Add permission options for the controller
                'permissions' => array_map(function ($value, $action) use ($class, $admin) {
                    $roles = array_keys(Config::get('decoy.site.roles'));

                    return (object) [
                        'slug' => $action,
                        'title' => is_array($value) ? $value[0] : Text::titleFromKey($action),
                        'description' => is_array($value) ? $value[1] : $value,

                        // Set the initial checked state based on the admin's permissions, if
                        // one is set.  Or based on the first role.
                        'checked' => $admin ?
                            $admin->can($action, $class) :
                            with(new Admin(['role' => $roles[0]]))->can($action, $class),

                        // Filter the list of roles to just the roles that allow the
                        // permission currently being iterated through
                        'roles' => array_filter($roles, function ($role) use ($action, $class) {
                            return with(new Admin(['role' => $role]))->can($action, $class);
                        }),

                    ];
                }, $permissions, array_keys($permissions)),
            ];
        }, $controllers);
    }
public static function getPermissionOptions ( $ admin = null ) { // Get all the app controllers $ controllers = array_map ( function ( $ path ) { return 'App\Http\Controllers\Admin\\' . basename ( $ path , '.php' ) ; } , glob ( app_path ( '/Http/Controllers/Admin/*.php' ) ) ) ; // Add some Decoy controllers $ controllers [ ] = 'Bkwld\Decoy\Controllers\Admins' ; $ controllers [ ] = 'Bkwld\Decoy\Controllers\Changes' ; $ controllers [ ] = 'Bkwld\Decoy\Controllers\Elements' ; $ controllers [ ] = 'Bkwld\Decoy\Controllers\RedirectRules' ; // Alphabetize the controller classes usort ( $ controllers , function ( $ a , $ b ) { return substr ( $ a , strrpos ( $ a , '\\' ) + 1 ) > substr ( $ b , strrpos ( $ b , '\\' ) + 1 ) ; } ) ; // Convert the list of controller classes into the shorthand strings used // by Decoy Auth as well as english name and desciption return array_map ( function ( $ class ) use ( $ admin ) { $ obj = new $ class ; $ permissions = $ obj -> getPermissionOptions ( ) ; if ( ! is_array ( $ permissions ) ) { $ permissions = [ ] ; } // Build the controller-level node return ( object ) [ // Add controller information 'slug' => DecoyURL :: slugController ( $ class ) , 'title' => $ obj -> title ( ) , 'description' => $ obj -> description ( ) , // Add permission options for the controller 'permissions' => array_map ( function ( $ value , $ action ) use ( $ class , $ admin ) { $ roles = array_keys ( Config :: get ( 'decoy.site.roles' ) ) ; return ( object ) [ 'slug' => $ action , 'title' => is_array ( $ value ) ? $ value [ 0 ] : Text :: titleFromKey ( $ action ) , 'description' => is_array ( $ value ) ? $ value [ 1 ] : $ value , // Set the initial checked state based on the admin's permissions, if // one is set.  Or based on the first role. 'checked' => $ admin ? $ admin -> can ( $ action , $ class ) : with ( new Admin ( [ 'role' => $ roles [ 0 ] ] ) ) -> can ( $ action , $ class ) , // Filter the list of roles to just the roles that allow the // permission currently being iterated through 'roles' => array_filter ( $ roles , function ( $ role ) use ( $ action , $ class ) { return with ( new Admin ( [ 'role' => $ role ] ) ) -> can ( $ action , $ class ) ; } ) , ] ; } , $ permissions , array_keys ( $ permissions ) ) , ] ; } , $ controllers ) ; }
Get the list of all permissions

@param  Admin|null $admin
@return array
Get the list of all permissions