Laravel - 航海者管理员调光器统计

Laravel - voyager admin dimmer statistic

我有 laravel 带有航海者管理面板的项目。现在我需要在我的管理仪表板上查看商店中产品的统计数据,但只能从今天开始。所以它需要向我展示今天生产的所有产品,以计算它并在我的 dashboard.Let 上展示它 我展示我的代码: 这是我的 DeltaDimmer.php:

<?php

namespace TCG\Voyager\Widgets;

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use TCG\Voyager\Facades\Voyager;
use Carbon\Carbon;
use App\Storeone;

class DeltaDimmer extends BaseDimmer
{
    /**
     * The configuration array.
     *
     * @var array
     */
    protected $config = [];

    /**
     * Treat this method as a controller action.
     * Return view() or other content to display.
     */
    public function run()
    {
        $count = Storeone::where('created_at', '=', Carbon::today())->count();
        //$count = \App\Storeone::where('created_at', '=', Carbon::today())->count();
        $string = 'Rad: ';

        return view('voyager::dimmer', array_merge($this->config, [
            'icon'   => 'voyager-eye',
            'title'  => "{$string} {$count}",
            'text'   => 'Optika Podgorica/Delta',
            'button' => [
                'text' => 'Prikazi',
                'link' => route('voyager.optikadelta.index'),
            ],
            'image' => voyager_asset('images/widget-backgrounds/04.jpeg'),
        ]));
    }

    /**
     * Determine if the widget should be displayed.
     *
     * @return bool
     */
    public function shouldBeDisplayed()
    {
        return Auth::user()->can('browse', Voyager::model('Post'));
    }
}

所以这是我的DeltaDimmer.php。这一行 $count = Storeone::where('created_at', '=', Carbon::today())->count(); 应该只在今天计算我在 Storeone 中的产品,但现在它显示 0,我做了一些产品只是为了测试。我做错了什么?

使用 whereDate 而不是仅与 where

进行比较
$count = Storeone::whereDate('created_at', Carbon::today())->count();