database/seeds/RolesAndPermission.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        app()['cache']->forget('spatie.permission.cache');
        Permission::create(['name' => 'create user']);
        Permission::create(['name' => 'read user']);
        Permission::create(['name' => 'update user']);
        Permission::create(['name' => 'delete user']);
        Permission::create(['name' => 'create role']);
        Permission::create(['name' => 'read role']);
        Permission::create(['name' => 'update role']);
        Permission::create(['name' => 'delete role']);
        Permission::create(['name' => 'create permission']);
        Permission::create(['name' => 'read permission']);
        Permission::create(['name' => 'update permission']);
        Permission::create(['name' => 'delete permission']);
        $role = Role::create(['name' => 'admin']);
        $role->givePermissionTo(Permission::all());
        $role = Role::create(['name' => 'client']);
        $role->givePermissionTo('read user');        
    }
public function run ( ) { app ( ) [ 'cache' ] -> forget ( 'spatie.permission.cache' ) ; Permission :: create ( [ 'name' => 'create user' ] ) ; Permission :: create ( [ 'name' => 'read user' ] ) ; Permission :: create ( [ 'name' => 'update user' ] ) ; Permission :: create ( [ 'name' => 'delete user' ] ) ; Permission :: create ( [ 'name' => 'create role' ] ) ; Permission :: create ( [ 'name' => 'read role' ] ) ; Permission :: create ( [ 'name' => 'update role' ] ) ; Permission :: create ( [ 'name' => 'delete role' ] ) ; Permission :: create ( [ 'name' => 'create permission' ] ) ; Permission :: create ( [ 'name' => 'read permission' ] ) ; Permission :: create ( [ 'name' => 'update permission' ] ) ; Permission :: create ( [ 'name' => 'delete permission' ] ) ; $ role = Role :: create ( [ 'name' => 'admin' ] ) ; $ role -> givePermissionTo ( Permission :: all ( ) ) ; $ role = Role :: create ( [ 'name' => 'client' ] ) ; $ role -> givePermissionTo ( 'read user' ) ; }
Run the database seeds.
Run the database seeds .