我有航海家管理面板的laravel项目。现在,我需要在我的管理仪表板上看到商店产品的统计数据,但只从今天开始。所以它需要向我展示今天生产的所有产品,来计数并在我的dashboard.Let上展示它。展示我的代码:这是我的DeltaDimmer.php
<?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,我做了几个产品只是为了测试。我哪里做错了?
发布于 2020-03-11 19:21:09
使用whereDate而不是仅与where进行比较
$count = Storeone::whereDate('created_at', Carbon::today())->count();https://stackoverflow.com/questions/60634781
复制相似问题