255, ], ]; } /** * @inheritdoc */ public function scenarios() { // bypass scenarios() implementation in the parent class return Model::scenarios(); } /** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Product::find() ->joinWith('lang') ->joinWith('brand.lang') ->joinWith('category.lang'); // add conditions that should always apply here $dataProvider = new ActiveDataProvider( [ 'query' => $query, 'sort' => [ 'attributes' => [ 'id', 'title' => [ 'asc' => [ 'product_lang.title' => SORT_ASC ], 'desc' => [ 'product_lang.title' => SORT_DESC ], 'default' => SORT_ASC, ], 'brand_title' => [ 'asc' => [ 'brand_lang.title' => SORT_ASC ], 'desc' => [ 'brand_lang.title' => SORT_DESC ], 'default' => SORT_ASC, ], 'created_at', 'status', 'sort', ], ], ] ); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere( [ 'product.id' => $this->id, 'product.status' => $this->status, ] ) ->andFilterWhere( [ 'like', 'product_lang.title', $this->title, ] ) ->andFilterWhere( [ 'like', 'brand_lang.title', $this->brand_title, ] ) ->andFilterWhere( [ 'category.id' => $this->category_title, ] ); return $dataProvider; } }