Skip to content

Instantly share code, notes, and snippets.

@hmic
Created January 26, 2016 13:23
Show Gist options
  • Save hmic/8b66418062eccba1dfd0 to your computer and use it in GitHub Desktop.
Save hmic/8b66418062eccba1dfd0 to your computer and use it in GitHub Desktop.
public function initialize() {
// ...
$this->loadModel('Historico');
// ...
}
public function add()
{
$solicitud = $this->Solicitud->newEntity();
if ($this->request->is('post')) {
$data = [
'estado' => '1',
'observaciones' => 'por fin',
'solicitud' => '1',
'usuario' => 'lina'
];
$entity = $this->Historico->newEntity($data);
$this->Historico->save($entity);
$solicitud = $this->Solicitud->patchEntity($solicitud, $this->request->data);
if ($this->Solicitud->save($solicitud)) {
$this->Flash->success(__('La Solicitud ha sido Creada con Exito.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('La Solicitud no se puede Crear. Por favor, intentelo de nuevo.'));
}
}
$this->set(compact('solicitud'));
$this->set('_serialize', ['solicitud']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment