generated from panliang/owl-admin-starter
42 lines
873 B
PHP
42 lines
873 B
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
use Maatwebsite\Excel\Concerns\Exportable;
|
|
use App\Admin\Services\UserRankService;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
|
|
class UserRank implements FromQuery, WithHeadings, WithMapping
|
|
{
|
|
use Exportable;
|
|
|
|
protected $index = 0;
|
|
|
|
public function query()
|
|
{
|
|
return UserRankService::make()->listQuery();
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
__('user_rank.cate_id'),
|
|
__('user_rank.user_id'),
|
|
__('user_rank.sort'),
|
|
__('user_rank.score'),
|
|
];
|
|
}
|
|
|
|
public function map($item): array
|
|
{
|
|
return [
|
|
$item->cate?->name,
|
|
$item->user?->name,
|
|
++$this->index,
|
|
$item->score,
|
|
];
|
|
}
|
|
}
|