|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?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->query = $this->loadService(UserGroupRepositoryQuery::class);
- }
-
- public function getDefaultOptionsSearch(): array
- {
- return [
- 'with' => [],
- 'join_with' => [],
- 'orderby' => '',
- 'attribute_id_producer' => ''
- ];
- }
-
- public function findOneUserGroupById(int $id)
- {
- return UserGroup::searchOne(['id' => $id]);
- }
-
- public function findOneUserGroupByName(string $name)
- {
- return UserGroup::searchOne(['name' => $name]);
- }
-
- public function findUserGroups()
- {
- return UserGroup::find()->where('id_producer = ' . GlobalParam::getCurrentProducerId())->all();
- }
-
- public function populateUserGroupDropdownList(): array
- {
- $userGroupsArrayDropdown = ['' => '--'];
- $userGroupsArray = $this->findUserGroups();
-
- foreach ($userGroupsArray as $userGroup) {
- $userGroupsArrayDropdown[$userGroup['id']] = $userGroup['name'];
- }
-
- return $userGroupsArrayDropdown;
- }
- }
|