I have the following code for creating a report:
$this->repository->create($request->all());
return response()->json(['sucesso' => 'Relatorio cadastrado com sucesso.']);
How do I get the created record ID and put it together in the reply?
I have the following code for creating a report:
$this->repository->create($request->all());
return response()->json(['sucesso' => 'Relatorio cadastrado com sucesso.']);
How do I get the created record ID and put it together in the reply?
Save the object in a variable, in this case $new
, try the following:
$new = $this->repository->create($request->all());
return response()->json(['sucesso' => 'Relatorio cadastrado com sucesso. ID: ' .$new->id]);