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