我有 voyager 管理面板的 laravel 項目?,F(xiàn)在我需要在我的管理儀表板上查看商店中產(chǎn)品的統(tǒng)計數(shù)據(jù),但僅限于今天。所以它需要向我展示今天生產(chǎn)的所有產(chǎn)品,計算它并在我的儀表板上顯示它。讓我展示我的代碼:這是我的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只計算我今天的產(chǎn)品,但現(xiàn)在它顯示為 0,我制作了一些產(chǎn)品只是為了測試。我做錯了什么?
1 回答
aluckdog
TA貢獻1847條經(jīng)驗 獲得超7個贊
使用whereDate而不是僅與比較where
$count = Storeone::whereDate('created_at', Carbon::today())->count();- 1 回答
- 0 關(guān)注
- 106 瀏覽
添加回答
舉報
0/150
提交
取消
