| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace App\Module\GameItems\AdminControllers\LazyRenderable;
- use App\Module\GameItems\Enums\ITEM_TYPE;
- use App\Module\GameItems\Models\Item;
- use App\Module\GameItems\Repositorys\ItemRepository;
- use Dcat\Admin\Grid;
- use UCore\DcatAdmin\Support\LazyRenderable;
- class ChestLazyRenderable extends \UCore\DcatAdmin\Grid\LazyRenderable
- {
- static $model = Item::class;
- static $repository = ItemRepository::class;
- public function grid(): Grid
- {
- // 获取外部传递的参数
- $id = $this->id;
- return Grid::make(new self::$repository, function (Grid $grid) {
- $grid->model()->where('type', ITEM_TYPE::CHEST);
- $grid->column('id');
- $grid->column('name');
- $grid->column('created_at');
- $grid->column('updated_at');
- $grid->quickSearch([ 'id', 'name' ]);
- $grid->paginate(10);
- $grid->disableActions();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->like('id')->width(4);
- $filter->like('name')->width(4);
- });
- });
- }
- }
|