57 lines
1.1 KiB
PHP
57 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Metrics;
|
|
|
|
use Dcat\Admin\Widgets\Metrics\Card;
|
|
use Illuminate\Contracts\Support\Renderable;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Order;
|
|
|
|
class TotalOrders extends Card
|
|
{
|
|
/**
|
|
* 卡片底部内容.
|
|
*
|
|
* @var string|Renderable|\Closure
|
|
*/
|
|
protected $footer;
|
|
|
|
/**
|
|
* 初始化卡片.
|
|
*/
|
|
protected function init()
|
|
{
|
|
parent::init();
|
|
|
|
$this->title('订单统计');
|
|
$this->subTitle('当前支付订单总数');
|
|
$this->content($this->getOrdersCount().'单');
|
|
}
|
|
/**
|
|
* 渲染卡片内容.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function renderContent()
|
|
{
|
|
$content = parent::renderContent();
|
|
|
|
return <<<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;
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取指定时间段用户数量
|
|
*/
|
|
public function getOrdersCount(){
|
|
return Order::where([
|
|
'order_status'=>1,
|
|
'pay_status'=>1
|
|
])->count();
|
|
}
|
|
}
|