GameConsumeGroupLazyRenderable.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\Module\Game\AdminControllers\LazyRenderable;
  3. use App\Module\Game\Models\GameConsumeGroup;
  4. use App\Module\Game\Repositories\GameConsumeGroupRepository;
  5. use Dcat\Admin\Grid;
  6. use UCore\DcatAdmin\Grid\LazyRenderable;
  7. use UCore\DcatAdmin\Grid\SelectTable;
  8. /**
  9. * 消耗组懒加载渲染类
  10. *
  11. * 用于在表单中选择消耗组时的数据表格渲染
  12. */
  13. class GameConsumeGroupLazyRenderable extends LazyRenderable implements SelectTable
  14. {
  15. /**
  16. * 获取模型
  17. *
  18. * @return string
  19. */
  20. public function getModel(): string
  21. {
  22. return GameConsumeGroup::class;
  23. }
  24. /**
  25. * 获取模型选择ID字段
  26. *
  27. * @return string
  28. */
  29. public function getModelSelectId(): string
  30. {
  31. return 'id';
  32. }
  33. /**
  34. * 获取模型显示名称字段
  35. *
  36. * @return string
  37. */
  38. public function getModelViewName(): string
  39. {
  40. return 'name';
  41. }
  42. /**
  43. * 构建表格
  44. *
  45. * @return Grid
  46. */
  47. public function grid(): Grid
  48. {
  49. return Grid::make(new GameConsumeGroupRepository(), function (Grid $grid) {
  50. $grid->column('id', 'ID')->sortable();
  51. $grid->column('name', '名称');
  52. $grid->column('code', '编码');
  53. $grid->column('description', '描述')->limit(30);
  54. $grid->column('created_at', '创建时间');
  55. $grid->quickSearch(['id', 'name', 'code']);
  56. $grid->filter(function (Grid\Filter $filter) {
  57. $filter->panel();
  58. $filter->equal('id', 'ID');
  59. $filter->like('name', '名称');
  60. $filter->like('code', '编码');
  61. });
  62. $grid->paginate(10);
  63. $grid->disableActions();
  64. $grid->disableBatchActions();
  65. $grid->disableCreateButton();
  66. });
  67. }
  68. }