/** * Displays a single Customers model. * @param integer $id * @return mixed */ public function actionView($id) { $model = $this->findModel($id); $city = Cities::findOne($model->city); $suburb = Suburbs::findOne($city->id); return $this->render('view', ['model' => $model, 'city' => $city->name, 'suburb' => $suburb->name]); }
/** * Finds the Cities model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Cities the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Cities::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }