Answer the question
In order to leave comments, you need to log in
How to properly organize the filter form?
There are ActiveRecord users (User):
class User extends \yii\db\ActiveRecord {
public function rules(){
return[
[
'first_name',
'last_name',
'login'
],
'string'
];
}
}
class UserFilter extends \yii\base\Model {
public $first_name;
public $last_name;
}
public static function SearchByFilter(UserFilter $filter) {
return self::find()->where(['last_name' => $filter->last_name, 'first_name' => $filter->first_name])
}
public function Search(){
return User::find()->where(['last_name' => $this->last_name, 'first_name' => $this->first_name])
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question