首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel - voyager管理调光器统计

Laravel - voyager管理调光器统计
EN

Stack Overflow用户
提问于 2020-03-11 19:17:15
回答 1查看 847关注 0票数 0

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

代码语言:javascript
复制
<?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,我做了几个产品只是为了测试。我哪里做错了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-11 19:21:09

使用whereDate而不是仅与where进行比较

代码语言:javascript
复制
$count = Storeone::whereDate('created_at', Carbon::today())->count();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60634781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档