コード例 #1
0
ファイル: SedesController.php プロジェクト: sacuriom/alba2
 /**
  * Creates a new Sede model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param integer $establecimiento_id
  * @return mixed
  */
 public function actionCreate($establecimiento_id)
 {
     $establecimiento = Establecimiento::findOne($establecimiento_id);
     $model = new Sede();
     $model->establecimiento_id = $establecimiento_id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['establecimientos/' . $model->establecimiento_id . '/sedes/view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
 /**
  * Finds the Establecimiento model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Establecimiento the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Establecimiento::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }