I'm doing an app with symfony3, I have the CRUD methods in the controller, but I can not insert data in the DB, for now I'm just doing the backend and testing with Postman. This is the method that inserts:
/**
* @Route("/event/new", name="new_event")
* @method({"POST"})
*/
public function newEvent(Request $request){
$event = new Evento();
$descripcion = $request->request->get('descripcion');
$obs = $request->request->get('obs');
$inicio = $request->request->get('inicio');
$fin = $request->request->get('fin');
$event->setDescripcion($descripcion);
$event->setObs($obs);
$event->setInicio(new \ DateTime ($inicio));
$event->setFin(new \DateTime($fin));
$em = $this->getDoctrine()->getManager();
$em->persist($event);
$em->flush();
return new Response("Folio: ". $event->getId());
}
It's as if I did not receive the parameters because I get this error:
An exception occurred while executing 'INSERT INTO evento (descripcion, obs, inicio, fin) VALUES (?, ?, ?, ?)' with params [null, null, "2018-04-09 22:20:03", "2018-04-09 22:20:03"]:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'descripcion' cannot be null
Any ideas on how to solve this? thanks