|
- <?php
-
- namespace common\logic\User\UserGroup\Repository;
-
- use common\helpers\GlobalParam;
- use common\logic\AbstractRepository;
- use common\logic\User\UserGroup\Model\UserGroup;
-
- class UserGroupRepository extends AbstractRepository
- {
- protected UserGroupRepositoryQuery $query;
-
- public function loadDependencies(): void
- {
- $this->loadQuery(UserGroupRepositoryQuery::class);
- }
-
- public function getDefaultOptionsSearch(): array
- {
- return [
- self::WITH => [],
- self::JOIN_WITH => [],
- self::ORDER_BY => '',
- self::ATTRIBUTE_ID_PRODUCER => 'user_group.id_producer'
- ];
- }
-
- public function findOneUserGroupById(int $id)
- {
- return $this->createDefaultQuery()
- ->filterById($id)
- ->findOne();
- }
-
- public function findOneUserGroupByName(string $name)
- {
- return $this->createDefaultQuery()
- ->filterByName($name)
- ->findOne();
- }
-
- public function findUserGroups()
- {
- return $this->createDefaultQuery()->find();
- }
-
- public function populateUserGroupDropdownList(): array
- {
- $userGroupsArrayDropdown = ['' => '--'];
- $userGroupsArray = $this->findUserGroups();
-
- foreach ($userGroupsArray as $userGroup) {
- $userGroupsArrayDropdown[$userGroup['id']] = $userGroup['name'];
- }
-
- return $userGroupsArrayDropdown;
- }
- }
|