@foreach($users as $user)
{{$user->name }}
@foreach($user->attendances as $attend)
@if( $attend->date->format('F') === $today->format('F') )
{{ $user->attendances->count() }}
@endif
@endforeach
@endforeach
答案=>总计数不是月份
答案 0 :(得分:0)
这是简单的解决方案,雄辩的有whereDate和whereMonth方法,
{{ $user->attendances()->whereMonth('created_at',\Carbon\Carbon::now()->format('m') )->count() }}
希望会有所帮助