1
Good evening, I’m trying to pull the contents of my database ordered by the created_at field, but in the view nothing appears, no error, but nothing from the bank appears on the other hand.
Code in the Homecontroller:
public function index()
{
$postagens = Postagens::orderBy('created_at','desc');
return view('index', compact('postagens'));
}
Code in view:
@foreach ($postagens as $pubs)
@postagens()
@slot('titulo')
{{$pubs->nomePost}}
@endslot
@slot('descricao')
{{$pubs->descricao}}
@endslot
@slot('nome')
{{$pubs->usuario}}
@endslot
@slot('dia')
{{$pubs->created_at}}
@endslot
@slot('id')
{{$pubs->id}}
@endslot
@endpostagens
@endforeach
Strange that is not appearing decreasingly yet, ta printing in order of insertion in the bank.
– spider tek
Try this: dd(Posts::toSql()) and see how this query is generated by Laravel.
– Weslley