| @@ 29-40 (lines=12) @@ | ||
| 26 | */ |
|
| 27 | public function crear() |
|
| 28 | { |
|
| 29 | if (Input::hasPost($this->model)) { |
|
| 30 | ||
| 31 | $obj = new $this->model; |
|
| 32 | //En caso que falle la operación de guardar |
|
| 33 | if (!$obj->save(Input::post($this->model))) { |
|
| 34 | Flash::error('Falló Operación'); |
|
| 35 | //se hacen persistente los datos en el formulario |
|
| 36 | $this->{$this->model} = $obj; |
|
| 37 | return; |
|
| 38 | } |
|
| 39 | return Redirect::to(); |
|
| 40 | } |
|
| 41 | // Sólo es necesario para el autoForm |
|
| 42 | $this->{$this->model} = new $this->model; |
|
| 43 | } |
|
| @@ 53-62 (lines=10) @@ | ||
| 50 | View::select('crear'); |
|
| 51 | ||
| 52 | //se verifica si se ha enviado via POST los datos |
|
| 53 | if (Input::hasPost($this->model)) { |
|
| 54 | $obj = new $this->model; |
|
| 55 | if (!$obj->update(Input::post($this->model))) { |
|
| 56 | Flash::error('Falló Operación'); |
|
| 57 | //se hacen persistente los datos en el formulario |
|
| 58 | $this->{$this->model} = Input::post($this->model); |
|
| 59 | } else { |
|
| 60 | return Redirect::to(); |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| 64 | //Aplicando la autocarga de objeto, para comenzar la edición |
|
| 65 | $this->{$this->model} = (new $this->model)->find((int) $id); |
|