src/Models/User.php
public function syncPermissions(array $permissions)
    {
        $permissionIds = [];
        foreach ($permissions as $name) {
            $permissionIds[] = app(Permission::class)->firstOrCreate(['name' => $name])->id;
        }
        $this->permissions()->sync($permissionIds);
    }
public function syncPermissions(array $permissions)
    {
        $permissionIds = [];
        foreach ($permissions as $name) {
            $permissionIds[] = app(Permission::class)->firstOrCreate(['name' => $name])->id;
        }
        $this->permissions()->sync($permissionIds);
    }
public function syncPermissions ( array $ permissions ) { $ permissionIds = [ ] ; foreach ( $ permissions as $ name ) { $ permissionIds [ ] = app ( Permission :: class ) -> firstOrCreate ( [ 'name' => $ name ] ) -> id ; } $ this -> permissions ( ) -> sync ( $ permissionIds ) ; }
Sync permissions.

@param array $permissions

@return null
Sync permissions .