Get Registry ID created Laravel 5

Asked

Viewed 1,176 times

0

I have the code below to create a report:

$this->repository->create($request->all());
return response()->json(['sucesso' => 'Relatorio cadastrado com sucesso.']);

How do I get the registry ID created and send together in response?

1 answer

2


Store the object in a variable, in this case the $new, try the following:

$new = $this->repository->create($request->all());
return response()->json(['sucesso' => 'Relatorio cadastrado com sucesso. ID: ' .$new->id]);
  • Perfect @Miguel thanks! (I will wait the minimum time to mark as correct)

  • You’re welcome @Raylansoares, I’m glad you solved

Browser other questions tagged

You are not signed in. Login or sign up in order to post.