Seed permissions.

@param  array  $seeds
972379
public function seed(array $seeds)
    {
        foreach ($seeds as $seed) {
            /** @var  \Arcanesoft\Auth\Models\PermissionsGroup  $group */
            $group       = PermissionsGroup::create($seed['group']);
            $permissions = array_map(function ($permission) {
                return new Permission($permission);
            }, $seed['permissions']);

            $group->permissions()->saveMany($permissions);
        }
    }
1314077
protected function assignPermissions(array $config) : void
    {
        $this->stdout("Assign permissions: " . count($config) . "\n", Console::FG_YELLOW);
        foreach ($config as $item) {
            if (!$permission = $this->assignPermission($item)) {
                $this->stdout("\t- error assigned permission: " . Json::encode($item) . "\n", Console::FG_RED);
            }
        }
    }
767386
public function addPermissions($permissions) {
		foreach ($permissions as $permission) {
			$per                                 = new permission($permission);
			$this->role->sharedPermissionList [] = $per->get();
		}
		R::store($this->role);
	}
97736
protected function yamlArrayToModel($array)
    {
        $filePermissions = $array;
        $permissions = [];
        $index = 0;

        foreach ($filePermissions as $code=>$permission) {
            $permission['permission'] = $code;

            $permissions[] = $permission;
        }

        $this->permissions = $permissions;
    }
1080245
private function restrictPermissions(array $userPermission, array $permissions)
    {
        return $this->mapPermissions($userPermission, $permissions, function($permission1, $permission2) {
            return $permission1 && $permission2;
        });
    }
502619
public function run(): void
    {
        foreach ($this->seed as $key => $value) {
            $this->call($this->each, $value, $key);
        }
    }
959766
private function preloadSharingRolePermissions(array $subjects): void
    {
        if (null !== $this->sharingManager) {
            $this->sharingManager->preloadRolePermissions($subjects);
        }
    }
379961
@Override
    public void setSeed(long seed) {
        if (initialized) {
            throw new UnsupportedOperationException();
        }
        initialized = true;
        rnd = (seed ^ multiplier) & mask;
    }
369547
public function assignProfiles($profiles) : void
    {
        $profiles = (array) $profiles;
        foreach ($profiles as $profile) {
            $electedProfile = Profile::where('code', $profile)->first();

            // Profile exists and not assigned to user?
            if (!is_null($electedProfile) && !$this->hasProfile($profile)) {
                // Assign both role and permissions defined for this user profile.
                // Into the Spatie Permissions.
                $this->assignRole(Role::find([$electedProfile->role_id])->first()->name);
                $this->givePermissionTo(Permission::find([$electedProfile->permission_id])->first()->name);

                // Assign user profile into the profiles table.
                $this->profiles()->save($electedProfile);
            }
        }
    }
1315439
public function seed(array $roles)
    {
        Role::query()->insert(
            $this->prepareRoles($roles)
        );

        $this->syncAdminRole();
    }
1087091
protected function clearStorage(string $storage = null): void
    {
        if (empty($storage)) {
            $seedsReflection = new \ReflectionClass(get_class($this));
            $storage = strtolower(str_replace('Seeds', '', $seedsReflection->getShortName()));
        }

        if (!$this->seeder->truncate($storage)) {
            throw new SeedsStorageException("Unable to clear seeds storage: {$storage}");
        }
    }
809824
public function setGroups(array $groups) {
		foreach ($groups as $title => $path) {
			$this->setGroup($title, $path);
		}
	}
562422
public function updatePermissions($permissions)
    {
        if ($this->isLink()) return;
        
        self::getDbConnection()->executeQuery('DELETE FROM users_groups_allow_cat WHERE catalog_id='.$this->id);
        if (is_array($permissions)) 
            foreach ($permissions as $pid => $groups)
                foreach($groups as $gid) if ($gid && $gid != GROUP_ADMIN)
                    self::getDbConnection()->executeQuery('INSERT INTO users_groups_allow_cat SET permission='.(int)$pid.', group_id='.(int)$gid.', catalog_id='.(int)$this->id);

    }
863794
@Override
    public void addPermissions(IPermission[] permissions) throws AuthorizationException {
        if (permissions.length > 0) {
            getPermissionStore().add(permissions);
            if (this.cachePermissions) {
                removeFromPermissionsCache(permissions);
            }
        }
    }
1136071
private function preloadPermissionsOfSharingRoles(array $objects): void
    {
        if (!$this->hasIdentityRoleable()) {
            return;
        }

        $subjects = $this->buildMapSubject($objects);

        foreach ($subjects as $id => $subject) {
            if (!isset($this->cacheRoleSharing[$id])
                    && isset($this->cacheSubjectSharing[$id]['sharings'])) {
                $this->buildCacheRoleSharing($this->cacheSubjectSharing[$id]['sharings'], $id);
            }
        }
    }
915579
public static function seedShuffle(&$array, $seed)
  {
      @mt_srand($seed);
      for ($i = count($array) - 1; $i > 0; --$i) {
          $j = @mt_rand(0, $i);
          $tmp = $array[$i];
          $array[$i] = $array[$j];
          $array[$j] = $tmp;
      }
  }
819559
protected function convertPermissions(array &$permissions) {
    $all_permissions = $this->getAllPermissions();

    foreach ($all_permissions as $name => $definition) {
      $key = array_search($definition['title'], $permissions);
      if (FALSE !== $key) {
        $permissions[$key] = $name;
      }
    }
  }