<?php namespace App\Store\Metrics\Examples; use App\Models\OrderInfo as OrderInfoModel; use Dcat\Admin\Widgets\Metrics\Card; use Illuminate\Contracts\Support\Renderable; use Illuminate\Http\Request; use Dcat\Admin\Admin; class WaitPickTotal extends Card { /** * 卡片底部内容. * * @var string|Renderable|\Closure */ protected $footer; protected $title; protected $type; public function __construct($title = null, $icon = null) { parent::__construct(); $this->title = $title; } /** * 初始化卡片. */ protected function init() { parent::init(); $this->title($this->title); } /** * 处理请求. * * @param Request $request * * @return void */ public function handle(Request $request) { switch ($request->get('option')) { case '365': case '1': case '7': default: $started = date("Y-m-01"); $ended = date("Y-m-t"); $order_status = [2]; $count = OrderInfoModel::getNumDayData($started, $ended, $order_status, Admin::user()->id); // 卡片内容 $this->withContent($count); // 图表数据 //$this->withChart($data['list']); } } /** * 设置卡片底部内容. * * @param string|Renderable|\Closure $footer * * @return $this */ public function footer($footer) { $this->footer = $footer; return $this; } /** * 设置卡片内容. * * @param string $content * * @return $this */ public function withContent($content) { return $this->content( <<<HTML <div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> <h2 class="ml-1 font-lg-1">{$content}</h2> </div> HTML ); } }