2
I am using Laravel 5.6 with Resource Controller. My show method:
public function show(Artigo $artigo)
{
$artigo = $artigo->first();
return view('painel.revista.detalhes', compact('artigo'));
}
It would be possible to ignore the line $artigo = $artigo->first();
and pass the variable directly to the view? I tried:
public function show(Artigo $artigo)
{
return view('painel.revista.detalhes', compact('artigo'));
}
However, I could not access the data in the view, I tried: {{ $artigo->titulo }}
but it didn’t work.
Article Collection was included as a parameter when running:
php artisan make:controller ConteudoController -m Models/Artigo
You’re only doing the injection so in the body you have to call the First().
– novic