/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Iva(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Iva'])) { $model->attributes = $_POST['Iva']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $tipo = ""; $porcentaje = ""; $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Iva'])) { $model->attributes = $_POST['Iva']; $iva = new Iva(); $iva->tipo = $model->tipo; $iva->porcentaje = $model->porcentaje; $model = $this->loadModel($id); $model->sys_status = false; if ($iva->save() && $model->save()) { $this->redirect(array('admin')); } } $this->render('update', array('model' => $model)); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { date_default_timezone_set('America/Caracas'); // Creamos un nuevo objeto $iva = new Iva(); // Obtenemos la data enviada por el usuario $data = Input::all(); // Revisamos si la data es válido if ($iva->isValid($data)) { // Si la data es valida se la asignamos $iva->fill($data); // Guardamos $iva->save(); // Y Devolvemos una redirección a la acción show para mostrar la información return Redirect::route('iva.show', array($iva->id))->with('create', 'El I.V.A. ha sido agregado correctamente.'); } else { // En caso de error regresa a la acción create con los datos y los errores encontrados return Redirect::route('iva.create')->withInput()->withErrors($iva->errors); } }