title('用户统计'); // $this->dropdown([ // '7' => '最近7天', // '30' => '最近30天', // '365' => '最近一年', // ]); } /** * 处理请求. * * @param Request $request * * @return void */ public function handle(Request $request) { $today_date = Carbon::today()->format('Y-m-d'); $total = User::query()->count(); $total_auth = User::query()->where('user_auth_level', User::user_auth_level_top)->count(); $today = User::query()->whereDate('created_at', $today_date)->count(); $today_auth = User::query()->whereDate('created_at', $today_date)->where('user_auth_level', User::user_auth_level_top)->count(); $this->withContent($total, $total_auth, $today, $today_auth); // 图表数据 $this->withChart([$total, $total_auth, $today_auth]); // 总数 $this->chartTotal('Total', $total); } /** * 设置卡片底部内容. * * @param string|Renderable|\Closure $footer * * @return $this */ public function footer($footer) { $this->footer = $footer; return $this; } /** * 设置图表数据. * * @param array $data * * @return $this */ public function withChart(array $data) { return $this->chart([ 'series' => $data, ]); } /** * 卡片内容. * * @param int $finished * @param int $pending * @param int $rejected * * @return $this */ public function withContent($total, $total_auth, $today, $today_auth) { $minHeight = '183px'; return $this->content( <<
用户类型
累计
今日新增
注册用户
{$total}
{$today}
实名用户
{$total_auth}
{$today_auth}
HTML ); } /** * 渲染卡片底部内容. * * @return string */ public function renderFooter() { return $this->toString($this->footer); } }