Level 102
Something like this? Add your own divs etc
@foreach ($sort as $date => $items )
{{$date}}
@foreach ($items as $item)
{{$item->person}}
@endforeach
@endforeach
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How can I display the query as a date with items underneath?
$sort = File::latest()->get()->groupBy(function($item)
{
return $item->date;
});
dd result
Illuminate\Database\Eloquent\Collection {#1227 ▼
#items: array:2 [▼
"2021-10-26" => Illuminate\Database\Eloquent\Collection {#1215 ▼
#items: array:1 [▼
0 => App\Models\File {#1231 ▼
#connection: "mysql"
#table: "files"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
+preventsLazyLoading: false
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#escapeWhenCastingToString: false
#attributes: array:15 [▼
"id" => 2
"file" => "Flote App Inc. cover letter_1637907373.pdf"
"class" => "first pdf"
"date" => "2021-10-26"
"account" => "pdf file"
"person" => "John"
"keyword" => "John, is, a, good, Boy"
"extension" => "pdf"
"description" => "This is a pdf text"
"orig_filename" => "Flote App Inc. cover letter.pdf"
"mime_type" => "application/pdf"
"filesize" => 65045
"content" => null
"created_at" => "2021-11-26 06:16:13"
"updated_at" => "2021-11-26 06:16:13"
]
Something like this? Add your own divs etc
@foreach ($sort as $date => $items )
{{$date}}
@foreach ($items as $item)
{{$item->person}}
@endforeach
@endforeach
Please or to participate in this conversation.