public function actionIndex($slug) { $query = Vidmage::find()->joinWith('vidmageAuthors.author')->where(['author.slug' => $slug])->orderBy(['id' => SORT_DESC]); $vidmages = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $author = Author::findOne(['slug' => $slug]); return $this->render('index', compact('vidmages', 'author')); }
/** * Finds the Author model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Author the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Author::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function beforeDelete() { if (parent::beforeDelete()) { $author = Author::findOne($this->author_id); $author->recount--; $author->save(); return true; } else { return false; } }
public function actionAccount($id) { $account = Author::findOne(['id' => $id]); if (!$account) { return $this->run('error'); } return $this->render('account', ['account' => $account]); }