Schools::find(), 'pagination' => [ 'pageSize' => 10, ], ]); return $this->render('index', [ 'dataProvider' => $dataProvider, ]); } public function actionView($translit) { $model = $this->findModel($translit); $video = Fields::getData($model->id,'Schools','video'); $phone = Fields::getData($model->id,'Schools','phone'); $price = Fields::getData($model->id,'Schools','price'); $trainers = $this->findTrainers($model->id); $spots_id = explode(',',$model->spots_id); $spots = Spots::findAll($spots_id); $dataSchools = new ArrayDataProvider([ 'allModels' => $spots, ]); return $this->render('view', [ 'model' => $model, 'spots' => $dataSchools, 'video' => $video, 'phone' => $phone, 'price' => $price, 'trainers' => $trainers, ]); } protected function findModel($translit) { if (($model = Schools::findOne(["translit"=>$translit])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } protected function findTrainers($id) { if (($model = Trainers::find()->where(['school_id'=>$id])->all()) !== null) { return $model; } else { return [new Trainers()]; } } }