You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.2KB

  1. <?php
  2. namespace common\logic\User\UserGroup\Repository;
  3. use common\helpers\GlobalParam;
  4. use common\logic\AbstractRepository;
  5. use common\logic\User\UserGroup\Model\UserGroup;
  6. class UserGroupRepository extends AbstractRepository
  7. {
  8. protected UserGroupRepositoryQuery $query;
  9. public function loadDependencies(): void
  10. {
  11. $this->query = $this->loadService(UserGroupRepositoryQuery::class);
  12. }
  13. public function getDefaultOptionsSearch(): array
  14. {
  15. return [
  16. 'with' => [],
  17. 'join_with' => [],
  18. 'orderby' => '',
  19. 'attribute_id_producer' => ''
  20. ];
  21. }
  22. public function findOneUserGroupById(int $id)
  23. {
  24. return UserGroup::searchOne(['id' => $id]);
  25. }
  26. public function findUserGroups()
  27. {
  28. return UserGroup::find()->where('id_producer = ' . GlobalParam::getCurrentProducerId())->all();
  29. }
  30. public function populateUserGroupDropdownList(): array
  31. {
  32. $userGroupsArrayDropdown = ['' => '--'];
  33. $userGroupsArray = $this->findUserGroups();
  34. foreach ($userGroupsArray as $userGroup) {
  35. $userGroupsArrayDropdown[$userGroup['id']] = $userGroup['name'];
  36. }
  37. return $userGroupsArrayDropdown;
  38. }
  39. }