I try to sort topics from the date of creation of the last post in each subject. Does anyone have any idea how to do this? Actually I recover everything well what I want, but not in the right order.
One topic has many poste and one poste belongsto one topic.
*: topic = sujet in the code. topics = lesSujets.
$lesSujets = Sujet::where('jeu_id', $idJeu)->paginate(20);
@foreach ($lesSujets as $sujet)
<tr>
<td><a href="{{route('sujet.show', $sujet->id)}}">{{$sujet->titre}}</a></td>
...
</tr>
I would like the topics to be sorted by last reply. The order should be: "your best card", "test 1", "aaaaa ..!", "[Firm] zzzz .."; We can know the last answer of a topic by $sujet->postes->last()->created_at (in the view of screenshot).