public function actionCategory($categoryId) { $category = RecipeCategory::findOne($categoryId); if (empty($category)) { throw new NotFoundHttpException('The requested page does not exist.'); } $searchModel = new PortionRepository(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render(['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'categoryName' => $category->name]); }
public function actionCategory($categoryId) { $category = RecipeCategory::findOne($categoryId); if (empty($category)) { throw new NotFoundHttpException('The requested page does not exist.'); } if ($this->isAjax()) { $model = new Portion(); $model->recipeCategoryId = $categoryId; return $this->renderPartial('@app/views/partials/_category-ingredients-dropdown-list', ['model' => $model, 'form' => ActiveForm::begin()]); } else { $searchModel = new RecipeRepository(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render(['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'categoryName' => $category->name]); } }
/** * Finds the RecipeCategory model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return RecipeCategory the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = RecipeCategory::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }