public function postGuardardepartamento() { $city = new Ciudad(); $city->departamento = Request::input('departamento'); $city->pais_id = Request::input('pais')['id']; $city->save(); return $city; }
/** * Creates a new Ciudad model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Ciudad(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function store() { try { $ciudad = new Ciudad(); $ciudad->ciudad = Request::input('ciudad'); $ciudad->departamento = Request::input('departamento'); $ciudad->pais_id = Request::input('pais_id'); $ciudad->save(); return $ciudad; } catch (Exception $e) { return $e; } }