нужно что бы при записи города, страны, области работал запрос по like , а не точному запросу
$query->andFilterWhere(['like', 'country', $this->country])
<?php
namespace common\models\search;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Order;
/**
* ArticleSearch represents the model behind the search form about `common\models\Article`.
*/
class OrderSearch extends Order
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id'], 'integer'],
[['id', 'carrying', 'type_truck', 'country'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Order::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'carrying' => $this->carrying,
'type_truck' => $this->type_truck,
'country' => $this->country,
]);
$query->andFilterWhere(['like', 'country', $this->country])
/*->andFilterWhere(['like', 'title', $this->title])
->andFilterWhere(['like', 'body', $this->body])*/;
return $dataProvider;
}
public function attributeLabels()
{
return [
'type_truck' => 'Тип транспорта',
'carrying' => 'Грузоподъемность',
'country' => 'Город / область'
];
}
}