Answer the question
In order to leave comments, you need to log in
How to pass a parameter to the model?
Guys tell me how to pass a parameter to the model.
I am using himiklab\sortablegrid and the TourPlayoff model has this code
'sort' => [
'class' => SortableGridBehavior::className(),
'sortableAttribute' => 'position',
'scope' => function ($query) {
$query->andWhere(['tour_id' => '? ']);
},
],
public function actions()
{
return [
'sort' => [
'class' => SortableGridAction::className(),
'modelName' => TourPlayoff::className(),
],
];
}
Answer the question
In order to leave comments, you need to log in
andWhere
Most likely something like this:
'sort' => [
'class' => SortableGridBehavior::className(),
'sortableAttribute' => 'position',
'scope' => function ($query) {
$query->andWhere(['tour_id' => ':tour'], [':tour' => Yii::$app->request->get('id')]);
},
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question