算今天的记录

Count today's records

我只需要统计今天的记录

   public function sales()
{

    $h = Carbon::now(); 
    $recordstoday = Eventos::All();


    $data = [
        'category_name' => 'dashboard',
        'page_name' => 'sales',
        'has_scrollspy' => 0,
        'scrollspy_offset' => '',
    ];

    return view('dashboard',compact('recordstoday','h'))->with($data);
}

现在它很重要,但我需要你计算今天的记录,今天使用 Carbon

 <h4 class="card-text text-center"><b>{{$turnoshoy->count('created_at')}}</b></h4>

您可以使用 whereDate

来计算
ModelName::whereDate('created_at',now())->count();

获取当前月份

$carbon=Carbon::now();

    ModelName::whereBetween('created_at',[
                                           $carbon->startOfMonth()->toDateString(),
                                           $carbon->endOfMonth()->toDateString()
                                      ])->count();

只需使用 Carbon::today()

$recordstoday = Eventos::whereDate('created_at', Carbon::today())->get();