@foreach ($hourRanges as $hourRange) @php // Dividir el rango en inicio y fin [$startHour, $endHour] = explode('-', $hourRange); $startHour = trim($startHour); $endHour = trim($endHour); @endphp {{ $hourRange }} @foreach ($sucursales as $sucursal) @php $startDateTime = now()->toDateString() . ' ' . $startHour; $endDateTime = now()->toDateString() . ' ' . $endHour; $monto = $documentos ->whereBetween('fecha_emision_pos', [$startDateTime, $endDateTime]) ->where('bodega_id', $sucursal->id) ->sum('monto'); /* dd($startDateTime, $endDateTime) */ @endphp ${{ number_format($monto, 2) }} @endforeach ${{ number_format( $documentos->whereBetween('fecha_emision_pos', [ now()->toDateString() . ' ' . $startHour, now()->toDateString() . ' ' . $endHour, ])->sum('monto'), 2,) }} @endforeach Total @foreach ($sucursales as $sucursal) ${{ number_format($documentos->where('bodega_id', $sucursal->id)->sum('monto'), 2) }} @endforeach ${{ number_format($documentos->sum('monto'), 2) }}