class InSearch extends In
{
public $couple_nomer;
public $dancerId1;
public $dancerId2;
public function rules()
{
return [
[['couple_nomer', 'dancerId1', 'dancerId2'], 'safe'],
];
}
public function search($params)
{
$query = In::find()->joinWith(['couple', 'tur', 'couple.dancerId1']);
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
return $dataProvider;
}
$query
->andFilterWhere(['like', 'couple.nomer', $this->couple_nomer])
->andFilterWhere(['like', 'couple.dancerId1.sname', $this->dancerId1])
->andFilterWhere(['like', 'couple.dancerId1.sname', $this->dancerId2]);
return $dataProvider;
}
}
$query = In::find()
->joinWith(['couple' => function(ActiveQuery $query){
$query->from(['c1' => Couple::tableName()])
}])
->joinWith(['couple' => function(ActiveQuery $query){
$query->from(['c2' => Couple::tableName()])
}]);
$query
->andFilterWhere(['like', 'couple.nomer', $this->couple_nomer])
->andFilterWhere(['like', 'c1.dancerId1.sname', $this->dancerId1])
->andFilterWhere(['like', 'c2.dancerId2.sname', $this->dancerId2]);
->joinWith(['couple' => function(ActiveQuery $query){
замените "couple" на имя связи public function search($params)
{
$query = In::find()
->joinWith(['couple', 'tur'])
->joinWith(['couple.dancerId1'=> function($q){
$q->from('dancer c1');
}])
->joinWith(['couple.dancerId2'=> function($q){
$q->from('dancer c2');
}]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
return $dataProvider;
}
$query
->andFilterWhere(['like', 'couple.nomer', $this->couple_nomer])
->andFilterWhere(['like', 'c1.sname', $this->dancerId1])
->andFilterWhere(['like', 'c2.sname', $this->dancerId2]);
return $dataProvider;
}