title('累计会员'); $this->contentWidth(5, 7); $this->chartLabels(UserInfo::$agentLevelTexts); $this->chartHeight(300); $this->chartOption('chart.width', '300'); $this->chartOption('dataLabels.enabled', true); $this->chartMarginBottom(50); $this->chart->style('float: none;'); $color = Admin::color(); $dark35 = $color->dark35(); $this->chartColors([ $color->primary(), $color->warning(), $color->danger(), $color->info(), $color->primary(), $color->warning(), $color->danger(), $color->info(), ]); } /** * 处理请求 * * @param Request $request * * @return mixed|void */ public function handle(Request $request) { // 卡片内容 $nums = UserInfo::selectRaw('count(1) as num, agent_level')->groupBy('agent_level')->pluck('num', 'agent_level')->toArray(); $this->withContent($nums); // dd($nums); // 图表数据 $this->withChart(array_merge($nums, [])); } /** * 设置图表数据. * * @param array $data * * @return $this */ public function withChart(array $data) { return $this->chart([ 'series' => $data, ]); } /** * 卡片内容. * * @param int $finished * @param int $pending * @param int $rejected * @param int $finished * @param int $pending * @param int $rejected * @param int $rejected * * @return $this */ public function withContent($userCount) { $civilian = Arr::get($userCount, UserInfo::AGENT_LEVEL_CIVILIAN, 0); $vip = Arr::get($userCount, UserInfo::AGENT_LEVEL_VIP, 0); $community = Arr::get($userCount, UserInfo::AGENT_LEVEL_COMMUNITY, 0); $district = Arr::get($userCount, UserInfo::AGENT_LEVEL_DISTRICT, 0); $city = Arr::get($userCount, UserInfo::AGENT_LEVEL_CITY, 0); $province = Arr::get($userCount, UserInfo::AGENT_LEVEL_PROVINCE, 0); $branch = Arr::get($userCount, UserInfo::AGENT_LEVEL_BRANCH, 0); $director = Arr::get($userCount, UserInfo::AGENT_LEVEL_DIRECTOR, 0); $totalNum = array_sum($userCount); return $this->content( <<