findModel($id); if ($model->parent_id == null){ $others = Service::find()->where(['parent_id' => $model->id])->all(); }else{ $others = Service::find()->where(['parent_id' => $model->parent_id])->all(); } $model->body = str_replace('[[prices]]', $this->renderPartial('_prices', ['prices' => $model->prices]), $model->body); return $this->render('view', [ 'model' => $model, 'others'=> $others ]); } public function findModel($id){ $model = Service::find() ->where(['id' => $id, 'status' => true]) ->with(['language.alias', 'image', 'prices' => function (ActiveQuery $query){ $query->where(['status' => true])->orderBy('sort'); }, 'comments' => function (ActiveQuery $query){ $query->where(['status' => true]); }, 'questions' => function (ActiveQuery $query){ $query->where(['status' => true]); }])->one(); if (empty($model)){ throw new NotFoundHttpException('Model not found'); } return $model; } }