|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?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;
- }
- }
|