| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- namespace App\Admin\Controllers;
- use App\Admin\Repositories\CouponRecord;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class CouponRecordController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new CouponRecord(['account']), function (Grid $grid) {
- $grid->column('id')->sortable();
- $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('add_cnt');
- $grid->column('type')->using(['','消耗','弹幕增加','打赏增加','兑换礼品增加','兑换礼包增加','新人礼包'])->label();
- $grid->column('record','记录明细')->display(function($v) {
- if($this->type == 1) {
- return '开盒记录';
- } elseif($this->type == 4) {
- return '兑换记录';
- }
- })->modal(function ($modal) {
- if($this->type == 1) {
- $modal->title('开礼盒记录');
- // 允许在闭包内返回异步加载类的实例
- if($this->box_record_id) {
- return \App\Admin\Renderable\BoxRecordTable::make(['id' => $this->box_record_id]);
- }
- return false;
- } elseif($this->type == 4) {
- $modal->title('礼品兑换记录');
- // 允许在闭包内返回异步加载类的实例
- if($this->gift_record_id) {
- return \App\Admin\Renderable\GiftRecordTable::make(['id' => $this->gift_record_id]);
- }
- return false;
- }
- });
- // $grid->column('gift_record_id')->display('查看')->modal(function ($modal) {
- // $modal->title('兑换记录');
- // // 允许在闭包内返回异步加载类的实例
- // if($this->gift_record_id) {
- // return \App\Admin\Renderable\GiftRecordTable::make(['id' => $this->gift_record_id]);
- // }
- // return false;
- // });
- $grid->column('pack_record_id');
- $grid->column('day');
- $grid->column('created_at');
- // $grid->column('updated_at')->sortable();
- $grid->model()->orderByDesc("id");
- $grid->disableActions();
- $grid->disableBatchDelete();
- $grid->disableRefreshButton();
- $grid->disableCreateButton();
- $grid->disableRowSelector();
- // $grid->simplePaginate();
- $grid->paginate(15);
- $grid->addTableClass(['table-text-center']);
- // $grid->disableToolbar();
- $grid->filter(function ($filter) {
- // 展开过滤器
- $filter->panel();
- $filter->expand();
- // $filter->equal('attire.cate', '类别')->select($this->cates)->width(2); // 设置编辑数据显示
- $filter->equal('account_id','用户名')->select(\App\Models\Account::pluck('username','id'))->width(3);
- $filter->equal('type')->select([1=>'消耗',2=>'弹幕增加',3=>'打赏增加',4=>'兑换礼品增加',5=>'兑换礼包增加',6=>'新人礼包'])->width(3); // 设置编辑数据显示
- });
- //
- $grid->tools(function (Grid\Tools $tools) {
- $tools->append(new \App\Admin\Actions\Grid\CouponSetAction());
- });
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new CouponRecord(), function (Show $show) {
- $show->field('id');
- $show->field('account_id');
- $show->field('add_cnt');
- $show->field('type');
- $show->field('gift_box_id');
- $show->field('gift_pack_id');
- $show->field('day');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new CouponRecord(), function (Form $form) {
- $form->display('id');
- $form->text('account_id');
- $form->text('add_cnt');
- $form->text('type');
- $form->text('gift_box_id');
- $form->text('gift_pack_id');
- $form->text('day');
- $form->display('created_at');
- $form->display('updated_at');
- });
- }
- }
|