亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Laravel - 航海者管理調光器統計

Laravel - 航海者管理調光器統計

PHP
暮色呼如 2022-10-28 14:19:09
我有 voyager 管理面板的 laravel 項目?,F在我需要在我的管理儀表板上查看商店中產品的統計數據,但僅限于今天。所以它需要向我展示今天生產的所有產品,計算它并在我的儀表板上顯示它。讓我展示我的代碼:這是我的DeltaDimmer.php:<?phpnamespace 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,我制作了一些產品只是為了測試。我做錯了什么?
查看完整描述

1 回答

?
aluckdog

TA貢獻1847條經驗 獲得超7個贊

使用whereDate而不是僅與比較where

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


查看完整回答
反對 回復 2022-10-28
  • 1 回答
  • 0 關注
  • 88 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號