60 lines
2.5 KiB
PHP
60 lines
2.5 KiB
PHP
<?php
|
||
|
||
namespace App\Admin\Renderable;
|
||
|
||
use App\Models\UserInfo;
|
||
use Dcat\Admin\Support\LazyRenderable;
|
||
use Illuminate\Support\Facades\DB;
|
||
|
||
class DealerSubordinateCard extends LazyRenderable
|
||
{
|
||
public function render()
|
||
{
|
||
// 获取外部传递的参数
|
||
$id = $this->id;
|
||
// dd($id);
|
||
$query = DB::table('users')
|
||
->join('user_infos', 'users.id', '=', 'user_infos.user_id')
|
||
->join('dealers', 'users.id', '=', 'dealers.user_id');
|
||
$userInfo = UserInfo::where('user_id', $id)->first();
|
||
// 查询数据逻辑
|
||
$data = [
|
||
'top'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 6)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(),
|
||
'secondary'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 5)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(),
|
||
'contracted'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 4)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(),
|
||
'special'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 3)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(),
|
||
'gold'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 2)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(),
|
||
];
|
||
|
||
// 这里可以返回内置组件,也可以返回视图文件或HTML字符串
|
||
return
|
||
<<<HTML
|
||
<div class="d-flex row text-center align-items-center justify-content-center" >
|
||
|
||
<div class="col-sm-4">
|
||
<h1 class="font-lg-1 mt-2 mb-0">{$data['top']}</h1>
|
||
一级经销商
|
||
</div>
|
||
<div class="col-sm-4">
|
||
<h1 class="font-lg-1 mt-2 mb-0">{$data['secondary']}</h1>
|
||
二级经销商
|
||
</div>
|
||
<div class="col-sm-4">
|
||
<h1 class="font-lg-1 mt-2 mb-0">{$data['contracted']}</h1>
|
||
签约经销商
|
||
</div>
|
||
</div>
|
||
<div class="d-flex row text-center align-items-center justify-content-center" >
|
||
<div class="col-sm-4">
|
||
<h1 class="font-lg-1 mt-2 mb-0">{$data['special']}</h1>
|
||
特邀经销商
|
||
</div>
|
||
<div class="col-sm-4">
|
||
<h1 class="font-lg-1 mt-2 mb-0">{$data['gold']}</h1>
|
||
金牌经销商
|
||
</div>
|
||
</div>
|
||
HTML;
|
||
}
|
||
}
|