Hi. Ive been trying a few different things and failing miserably, but what im trying to do is to group the collection by day/date and then the items inside that day are then ordered by title. In the controller the orderBy I have already orders the dates which is how I want it, but not sure how to order everything in the group.
Controller ::
$collection = CustomerScan::where('user_id', $user->id)
->orderBy('created_at', 'desc')
->get()
->groupBy(function ($item) {
return $item->created_at->format('Y-m-d');
});
Template::
@foreach ($collection as $date => $scans)
<div style="margin-top: 50px;">
<strong>{{ Carbon\Carbon::parse($date)->format('jS F Y') }}</strong>
<small style="float: right">
{{ $scans->count() }} {{ Illuminate\Support\Str::plural('Scan',$scans->count()) }}
</small>
</div>
<hr style="border-top: 1px #ccc solid;">
<div class="row midsection">
@foreach($scans->chunk(3) as $chunk)
@foreach($chunk as $scan)
<a href="{{ Storage::disk('s3')->temporaryUrl( $scan->scan_paths, now()->addMinutes(1)) }}" target="_blank">
@endforeach
@endforech
What I want is to order the scan images in title order but still have the date order in "desc" if that makes sense. Any help would be grateful.
Cheers