UserEpisodeRecord.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Admin\Actions\Grid;
  3. use App\Models\UserEpisodesRecord;
  4. use Dcat\Admin\Contracts\LazyRenderable;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Grid\RowAction;
  7. use Dcat\Admin\Traits\LazyWidget;
  8. class UserEpisodeRecord extends RowAction implements LazyRenderable
  9. {
  10. use LazyWidget;
  11. /**
  12. * @return string
  13. */
  14. protected $title = '消费记录';
  15. public function handle($a = '')
  16. {
  17. return $this->getKey();
  18. }
  19. public function grid()
  20. {
  21. $id = \request()->input('key');
  22. return Grid::make(UserEpisodesRecord::with(['user', 'episodes']), function (Grid $grid) use ($id) {
  23. $grid->model()->where('user_id', $id)->orderByDesc('created_at');
  24. $grid->column('id')->sortable();
  25. $grid->column('episodes.name', '短剧名称')->label('info');
  26. $grid->column('list_id', '第几集')->label('primary');
  27. $grid->column('platform', '所属平台')
  28. ->display(function () {
  29. return $this->user->info->platform;
  30. })
  31. ->using(config('global.platform'))
  32. ->label([1 => 'primary', 2 => 'success']);
  33. $grid->column('price', '金币')->label('danger');
  34. $grid->column('created_at', '消费时间');
  35. $grid->disableActions();
  36. $grid->disableRowSelector();
  37. $grid->disableToolbar();
  38. });
  39. }
  40. public function render()
  41. {
  42. return $this->grid();
  43. }
  44. }