Использую стандартный use yii\behaviors\SluggableBehavior;
Версия Yii 2.0.38.
Код: Выделить всё
[
'class' => SluggableBehavior::class,
'attribute' => 'title',
'immutable' => true,
],
Код: Выделить всё
class BrandSearch extends Brand
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'status'], 'integer'],
[['slug', 'title'], '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 = Brand::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'status' => $this->status,
]);
$query->andFilterWhere(['like', 'slug', $this->slug])
->andFilterWhere(['like', 'title', $this->title]);
return $dataProvider;
}
}
До последнего обновления компонентов такого не было. Это бага или я что-то где-то упустил?
Спасибо.