public static function createResource($resource, $system = false)
    {
        $group        = ucfirst($resource);
        $slug         = strtolower($group);
        $permissions  = [
            [
                'slug'     => $slug . '.view',
                'resource' => $group,
                'name'     => 'View ' . $group,
                'system'   => $system,
            ],
            [
                'slug'     => $slug . '.create',
                'resource' => $group,
                'name'     => 'Create ' . $group,
                'system'   => $system,
            ],
            [
                'slug'     => $slug . '.update',
                'resource' => $group,
                'name'     => 'Update ' . $group,
                'system'   => $system,
            ],
            [
                'slug'     => $slug . '.delete',
                'resource' => $group,
                'name'     => 'Delete ' . $group,
                'system'   => $system,
            ],
        ];

        $collection = new Collection;
        foreach ($permissions as $permission) {
            try {
                $collection->push(static::create($permission));
            } catch (\Exception $e) {
                // permission already exists.
            }
        }

        return $collection;
    }
public static function createResource($resource, $system = false)
    {
        $group        = ucfirst($resource);
        $slug         = strtolower($group);
        $permissions  = [
            [
                'slug'     => $slug . '.view',
                'resource' => $group,
                'name'     => 'View ' . $group,
                'system'   => $system,
            ],
            [
                'slug'     => $slug . '.create',
                'resource' => $group,
                'name'     => 'Create ' . $group,
                'system'   => $system,
            ],
            [
                'slug'     => $slug . '.update',
                'resource' => $group,
                'name'     => 'Update ' . $group,
                'system'   => $system,
            ],
            [
                'slug'     => $slug . '.delete',
                'resource' => $group,
                'name'     => 'Delete ' . $group,
                'system'   => $system,
            ],
        ];

        $collection = new Collection;
        foreach ($permissions as $permission) {
            try {
                $collection->push(static::create($permission));
            } catch (\Exception $e) {
                // permission already exists.
            }
        }

        return $collection;
    }
public static function createResource ( $ resource , $ system = false ) { $ group = ucfirst ( $ resource ) ; $ slug = strtolower ( $ group ) ; $ permissions = [ [ 'slug' => $ slug . '.view' , 'resource' => $ group , 'name' => 'View ' . $ group , 'system' => $ system , ] , [ 'slug' => $ slug . '.create' , 'resource' => $ group , 'name' => 'Create ' . $ group , 'system' => $ system , ] , [ 'slug' => $ slug . '.update' , 'resource' => $ group , 'name' => 'Update ' . $ group , 'system' => $ system , ] , [ 'slug' => $ slug . '.delete' , 'resource' => $ group , 'name' => 'Delete ' . $ group , 'system' => $ system , ] , ] ; $ collection = new Collection ; foreach ( $ permissions as $ permission ) { try { $ collection -> push ( static :: create ( $ permission ) ) ; } catch ( \ Exception $ e ) { // permission already exists. } } return $ collection ; }
Create a permissions for a resource.

@param $resource
@param bool $system
@return \Illuminate\Support\Collection
Create a permissions for a resource .