/**
  * Finds the CoachPosts model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CoachPosts the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CoachPosts::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 2
0
 public function getPosts()
 {
     return $this->hasMany(CoachPosts::className(), ['admin_id' => 'id']);
 }
Esempio n. 3
0
 public function actionIndex()
 {
     $posts = CoachPosts::find()->orderBy(['id' => SORT_DESC])->all();
     return $this->render('index');
 }
Esempio n. 4
0
 public function getPost()
 {
     return $this->hasOne(CoachPosts::className(), ['business_id' => 'id']);
 }