Get created registry ID Laravel 5

0

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?

    
asked by anonymous 17.11.2016 / 18:46

1 answer

2

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]);
    
17.11.2016 / 18:49