/** * find a document instance and returns it property typed. * * @return app\models\{Document,Bid,Order,Bill} the document */ public static function findCompetition($id) { $model = Competition::findOne($id); if ($model) { switch ($model->competition_type) { case self::TYPE_MATCH: return Match::findOne($id); break; case self::TYPE_TOURNAMENT: return Tournament::findOne($id); break; case self::TYPE_SEASON: return Season::findOne($id); break; } } return null; }
/** * Finds the Season model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Season the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Season::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }