我有 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();
- 1 回答
- 0 關注
- 88 瀏覽
添加回答
舉報
0/150
提交
取消