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