protected function findModel($id) { if (($model = Category::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionGetPrices() { $categoryId = (int) yii::$app->request->post('id'); $categoryModel = Category::findOne($categoryId); if (yii::$app->has('organization') && ($organization = yii::$app->organization->get())) { $services = Service::find()->where('(calculator = "" OR calculator IS NULL) AND organization_id = :org_id', [':org_id' => $organization->id])->orderBy('sort DESC, id ASC')->all(); $complexes = Complex::find()->where(['organization_id' => $organization->id])->orderBy('sort DESC, id ASC')->all(); } else { $services = Service::find()->where('calculator = "" OR calculator IS NULL')->orderBy('sort DESC, id ASC')->all(); $complexes = Complex::find()->orderBy('sort DESC, id ASC')->all(); } $priceModel = new Price(); $json = []; $json['HtmlBlock'] = $this->renderPartial('order-type/net/services', ['priceModel' => $priceModel, 'categoryId' => $categoryId, 'services' => $services, 'complexes' => $complexes, 'categoryModel' => $categoryModel]); die(json_encode($json)); }