Answer the question
In order to leave comments, you need to log in
How to make a selection from the database in yii2 using the rest api?
I use ActiveController as written in the documentation.
public function actionIndex()
{
$modelClass = $this->modelClass;
$developer = Developers::findOne([
'id' => Yii::$app->request->get('developer_id'),
]);
$complex_type = ComplexType::findOne([
'id' => Yii::$app->request->get('complex_id'),
]);
$complex = Complex::findOne([
'type_id' => $complex_type->id,
'developer_id' => $developer->id,
]);
$query = $modelClass::find()
->where(
[
'amount_room' => Yii::$app->request->get('amount_room'),
'yardage' => Yii::$app->request->get('yardage'),
'level' => Yii::$app->request->get('level'),
'complex_id' => $complex->id,
]);
return new ActiveDataProvider([
'query' => $query,
]);
}
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