/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $nombre = Input::get('nombre');
     $descripcion = Input::get('descripcion');
     $departamento = new Departamento();
     $departamento->nombre = $nombre;
     $departamento->descripcion = $descripcion;
     $departamento->save();
     Session::flash('message', 'Registro guardado satisfactoriamente!');
     return Redirect::to('departamentos');
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Departamento();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Departamento'])) {
         $model->attributes = $_POST['Departamento'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->dpto_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Departamento();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Departamento'])) {
         $model->attributes = $_POST['Departamento'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $propiedades = Propiedad::model()->findAll(array('select' => 'id,nombre'));
     $this->render('create', array('model' => $model, 'propiedades' => $propiedades));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Departamento();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Departamento'])) {
         $model->attributes = $_POST['Departamento'];
         $model->empresa_id = Yii::app()->user->empresa;
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store()
 {
     $Departamento = new Departamento();
     $Departamento->nombre = Input::get('nombre');
     $Departamento->descripcion = Input::get('descripcion');
     $Departamento->pais_id = Input::get('pais_id');
     $validar = Validator::make(Input::all(), $this->reglas);
     if ($validar->fails()) {
         $return['ok'] = false;
         $return['msg'] = $validar->messages();
         return $return;
     } else {
         if ($Departamento->save()) {
             $return['ok'] = true;
             $return['msg'] = 'La ciudad ha sido guardado';
             return $return;
         } else {
             $return['ok'] = false;
             $return['msg'] = 'No se pudo crear el registro';
             return $return;
         }
     }
 }