|
- <?php
-
- namespace common\logic\User\UserGroup;
-
- use common\helpers\GlobalParam;
- use common\logic\AbstractService;
- use common\logic\RepositoryInterface;
-
- class UserGroupRepository extends AbstractService implements RepositoryInterface
- {
- public function getDefaultOptionsSearch()
- {
- return [
- 'with' => [],
- 'join_with' => [],
- 'orderby' => '',
- 'attribute_id_producer' => ''
- ];
- }
-
- public function findOneUserGroupById(int $id)
- {
- return UserGroup::searchOne(['id' => $id]);
- }
-
- 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;
- }
- }
|