/** * 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.'); } }
public function getPosts() { return $this->hasMany(CoachPosts::className(), ['admin_id' => 'id']); }
public function actionIndex() { $posts = CoachPosts::find()->orderBy(['id' => SORT_DESC])->all(); return $this->render('index'); }
public function getPost() { return $this->hasOne(CoachPosts::className(), ['business_id' => 'id']); }