Thursday, January 23, 2020

Search-Filter with multi relations model in Yii2 Advanced

'label' => 'Category Title',
'attribute' => 'category_id',
'value' => function($model){
$category = backend\models\Categories::find()->where('category_id' =>$model->category_id)->one();
return $category->category_title;
}

2. ------- Remove category id from rules
3. Make join with other model
$query->leftJoin('categories', 'categories.category_id=products.category_id');

4. andWhere like
andFilterWhere(['like', 'categories.category_title', $this->category_id]);

No comments:

Post a Comment