1
I have the method responsible for calling a page (View
) which displays the data referring to the last id entered in the database and I am using the framework Laravel and ORM Eloquent
public function exibe(Request $id)
{
$dados = Denuncia::all()->sortByDesc('id')->first();
return view('DenunciaView.exibeDenuncia'['dados'=>$dados]);
}
However, I need to display the data referring to the inserted id, not necessarily the last one. For example, if the id entered was 1, the data displayed on the page (View
) refer to this id, and if another id is inserted, the displayed data refers to that other id.
However, if I update the page (View
) where the id data are being shown 1, the data is updated and the data of the last inserted id is displayed.
I’ve tried the method find
, clause where
but I was unsuccessful.
How are you calling this method on the route? Note: You are using the wrong ORM, bringing the data mass to then take only the first one, do this first and the code of the
Eloquent
without charge for the rest.– novic
Hello Virgilio, I thank you for your comment regarding the use of eloquent. I’m calling the method this way: Route::get('exibeInformacaDenunciacia','Admindenunciacontroller Informacoescontroller@mostra')->name('exibeInformacaoDenunciacia');
– frdmarkes
Cade the id at that url?
– novic
because eh, when I pass the id I get this message Missing required Parameters for [Route: exibeInformacaoDenuncia] [URI: controledenuncia/exibeInformacaoDenuncia/{id}].
– frdmarkes