|
- <?php
-
-
-
- namespace common\models ;
-
- use common\helpers\GlobalParam;
- use common\models\UserGroup ;
-
- class UserGroupSearch extends UserGroup
- {
-
- public function rules()
- {
- return [
- [['name'], 'string'],
- [['name'], 'string', 'max' => 255],
- ['id_producer', 'integer'],
- ];
- }
-
- public function search($params)
- {
- $optionsSearch = self::defaultOptionsSearch() ;
-
- $query = UserGroup::find()
- ->with($optionsSearch['with'])
- ->innerJoinWith($optionsSearch['join_with'], true)
- ->where(['user_group.id_producer' => GlobalParam::getCurrentProducerId()])
- ;
-
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- 'sort' => ['attributes' => ['name']],
- 'pagination' => [
- 'pageSize' => 20,
- ],
- ]);
-
- $this->load($params);
- if (!$this->validate()) {
- return $dataProvider;
- }
-
- $query->andFilterWhere(['like', 'user_group.name', $this->name]) ;
-
- return $dataProvider;
- }
-
- }
|