public function actionCategory($id) { if (!Yii::$app->user->can('show', Yii::$app->user->identity)) { Yii::$app->session->setFlash('expires', true); } $category = Categories::find()->where('id=:id', [':id' => $id])->one(); if (empty($category)) { throw new \yii\web\NotFoundHttpException(Yii::t('app', '<p>There are currently no pages of content associated with this category. Please check back again!</p>')); } return $this->render('category', compact('category')); }
public function init() { $this->categories = Categories::find()->orderBy('category')->all(); $this->pdfs = Pdfs::find()->count(); }
/** * @return \yii\db\ActiveQuery */ public function getCategories() { return $this->hasOne(Categories::className(), ['id' => 'categories_id']); }