|
- <?php
-
- namespace domain\User\UserGroup;
-
- use domain\_\AbstractRepository;
-
- 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(bool $emptyOption = true): array
- {
- $userGroupsArrayDropdown = [];
- if($emptyOption) {
- $userGroupsArrayDropdown = ['' => '--'];
- }
-
- $userGroupsArray = $this->findUserGroups();
- foreach ($userGroupsArray as $userGroup) {
- $userGroupsArrayDropdown[$userGroup['id']] = $userGroup['name'];
- }
-
- return $userGroupsArrayDropdown;
- }
- }
|