Laravel数据库通知如何仅显示当月创建的通知(显示当月通知)

Laravel数据库通知如何仅显示当月创建的通知(显示当月通知),laravel,Laravel,laravel数据库通知工作正常,但这里的问题是如何显示在系统当前年份和月份创建的通知 <?php $user = App\User::first(); foreach($user->unreadNotifications as $notification):?> <h4> {{$notification->data['name']}} <small><i class="fa fa-clock-o"> &

laravel数据库通知工作正常,但这里的问题是如何显示在系统当前年份和月份创建的通知

<?php
$user = App\User::first();
foreach($user->unreadNotifications as $notification):?>
<h4>
    {{$notification->data['name']}}
    <small><i class="fa fa-clock-o">
        </i>{{$notification->created_at->diffForHumans()}}</small>
</h4>
</a>
<?php endforeach;?>

{{$notification->data['name']}
{{$notification->created_at->diffForHumans()}

取当前年份月份,并将其与创建通知的日期(仅限年-月)进行比较。这是密码

<?php
$user = App\User::first();
$currentMonth = date('Y-m');
foreach($user->unreadNotifications as $notification):
if(date('Y-m',strtotime($notification->created_at)) == $currentMonth);?>
<h4>
    {{$notification->data['name']}}
    <small><i class="fa fa-clock-o">
        </i>{{$notification->created_at->diffForHumans()}}</small>
</h4>
</a>
<?php endif;
endforeach;?>

{{$notification->data['name']}
{{$notification->created_at->diffForHumans()}

作为最后一点,我们希望说明通知工作正常,但我只想显示当月创建的通知,而不是最后一个月。当有人回答我的问题时,我该怎么办?