您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

59 行
1.4KB

  1. <?php
  2. namespace domain\User\UserGroup;
  3. use domain\_\AbstractRepository;
  4. class UserGroupRepository extends AbstractRepository
  5. {
  6. protected UserGroupRepositoryQuery $query;
  7. public function loadDependencies(): void
  8. {
  9. $this->loadQuery(UserGroupRepositoryQuery::class);
  10. }
  11. public function getDefaultOptionsSearch(): array
  12. {
  13. return [
  14. self::WITH => [],
  15. self::JOIN_WITH => [],
  16. self::ORDER_BY => '',
  17. self::ATTRIBUTE_ID_PRODUCER => 'user_group.id_producer'
  18. ];
  19. }
  20. public function findOneUserGroupById(int $id)
  21. {
  22. return $this->createDefaultQuery()
  23. ->filterById($id)
  24. ->findOne();
  25. }
  26. public function findOneUserGroupByName(string $name)
  27. {
  28. return $this->createDefaultQuery()
  29. ->filterByName($name)
  30. ->findOne();
  31. }
  32. public function findUserGroups()
  33. {
  34. return $this->createDefaultQuery()->find();
  35. }
  36. public function populateUserGroupDropdownList(bool $emptyOption = true): array
  37. {
  38. $userGroupsArrayDropdown = [];
  39. if($emptyOption) {
  40. $userGroupsArrayDropdown = ['' => '--'];
  41. }
  42. $userGroupsArray = $this->findUserGroups();
  43. foreach ($userGroupsArray as $userGroup) {
  44. $userGroupsArrayDropdown[$userGroup['id']] = $userGroup['name'];
  45. }
  46. return $userGroupsArrayDropdown;
  47. }
  48. }