0
how do I display in the view only the data of the last saved record in the database? I can display all the data by calling the All() method in the control, and the good old foreach in the view to display the data. However, he wanted that when the user finishes the registration he was redirected to a page, where he could check the data that registered.
Obs:I’m using Laravel, eloquent Orm, mysql
in control I have this action to get all the data
public function exibe(){
$dados = Denuncia::all();
return view('AdminDenunciaView.exibeInformacao',['dados'=>$dados]);
}
in view use this foreach to display the data
@foreach ($dados as $item)
{{$item->crime}}.<br/>
{{$item->infrator}}.<br/>
@endforeach
But as I mentioned, I don’t need all the data to be shown, just the last record data
mysqli_insert_id - Returns the automatically generated id in the last query. With this you select with Where nameColuna = automatically generated id in the last https://www.php.net/manual/en/mysqli.insert-id.phpquery
– user60252