| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Module\Game\AdminControllers\LazyRenderable;
- use App\Module\Game\Models\GameConsumeGroup;
- use App\Module\Game\Repositories\GameConsumeGroupRepository;
- use Dcat\Admin\Grid;
- use UCore\DcatAdmin\Grid\LazyRenderable;
- use UCore\DcatAdmin\Grid\SelectTable;
- /**
- * 消耗组懒加载渲染类
- *
- * 用于在表单中选择消耗组时的数据表格渲染
- */
- class GameConsumeGroupLazyRenderable extends LazyRenderable implements SelectTable
- {
- /**
- * 获取模型
- *
- * @return string
- */
- public function getModel(): string
- {
- return GameConsumeGroup::class;
- }
- /**
- * 获取模型选择ID字段
- *
- * @return string
- */
- public function getModelSelectId(): string
- {
- return 'id';
- }
- /**
- * 获取模型显示名称字段
- *
- * @return string
- */
- public function getModelViewName(): string
- {
- return 'name';
- }
- /**
- * 构建表格
- *
- * @return Grid
- */
- public function grid(): Grid
- {
- return Grid::make(new GameConsumeGroupRepository(), function (Grid $grid) {
- $grid->column('id', 'ID')->sortable();
- $grid->column('name', '名称');
- $grid->column('code', '编码');
- $grid->column('description', '描述')->limit(30);
- $grid->column('created_at', '创建时间');
- $grid->quickSearch(['id', 'name', 'code']);
- $grid->filter(function (Grid\Filter $filter) {
- $filter->panel();
- $filter->equal('id', 'ID');
- $filter->like('name', '名称');
- $filter->like('code', '编码');
- });
- $grid->paginate(10);
- $grid->disableActions();
- $grid->disableBatchActions();
- $grid->disableCreateButton();
- });
- }
- }
|