我有 voyager 管理面板的 laravel 項(xiàng)目?,F(xiàn)在我需要在我的管理儀表板上查看商店中產(chǎn)品的統(tǒng)計(jì)數(shù)據(jù),但僅限于今天。所以它需要向我展示今天生產(chǎn)的所有產(chǎn)品,計(jì)算它并在我的儀表板上顯示它。讓我展示我的代碼:這是我的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();應(yīng)該Storeone只計(jì)算我今天的產(chǎn)品,但現(xiàn)在它顯示為 0,我制作了一些產(chǎn)品只是為了測(cè)試。我做錯(cuò)了什么?
1 回答

aluckdog
TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個(gè)贊
使用whereDate
而不是僅與比較where
$count = Storeone::whereDate('created_at', Carbon::today())->count();
- 1 回答
- 0 關(guān)注
- 98 瀏覽
添加回答
舉報(bào)
0/150
提交
取消