| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Admin\Renderable;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Grid\LazyRenderable;
- use App\Admin\Repositories\PackRecord;
- class PackRecordTable extends LazyRenderable
- {
- public function grid(): Grid
- {
- return Grid::make(new PackRecord(['account','giftPack']), function (Grid $grid) {
- //
- $grid->column('account.uid','用户UID');
- $grid->column('account.avatar','用户头像')->image(config("filesystems.disks.cosv5.url"), 60, 60);
- $grid->column('account.username','用户名称')->display(function($v) {
- return "<a href='/admin/accounts?id={$this->account_id}' target='_blank'>{$v}</a>";
- });
- $grid->column('giftPack.name', '礼包名称');
- $grid->column('cost_coupons','花费礼劵');
- $grid->column('created_at','兑换时间');
- $grid->withBorder();
- $grid->model()->orderByDesc("id");
- $grid->paginate(10);
- $grid->disableActions();
- $grid->rowSelector()->titleColumn('name');
- //
- $grid->filter(function (Grid\Filter $filter) {
- // 展开过滤器
- $filter->panel();
- $filter->expand();
- $filter->withoutInputBorder();
- // 在这里添加字段过滤器
- // $filter->equal('id')->width(2);
- $filter->where('aid', function ($query) {
- $query->whereHas('account', function ($query) {
- $query->where('uid', $this->input);
- });
- }, '用户UID')->width(3);
- $filter->equal('account_id','用户名')->select(\App\Models\Account::pluck('username','id'))->width(3);
- });
- });
- }
- }
|