AttireTable.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Admin\Renderable;
  3. use Dcat\Admin\Grid;
  4. use Dcat\Admin\Grid\LazyRenderable;
  5. use App\Admin\Repositories\Attire;
  6. class AttireTable extends LazyRenderable
  7. {
  8. public $cates = [
  9. '套装' => '套装',
  10. '皮肤' => '皮肤',
  11. ];
  12. public $levels = [
  13. 'N' => 'N',
  14. 'R' => 'R',
  15. 'SR' => 'SR',
  16. 'SSR' => 'SSR',
  17. ];
  18. public function grid(): Grid
  19. {
  20. // 获取外部传递的参数
  21. $id = $this->id;
  22. return Grid::make(new Attire(), function (Grid $grid) {
  23. //
  24. $grid->column('name');
  25. $grid->column('cate', '类别');
  26. $grid->column('img_1', '正面图片')->image(config("filesystems.disks.cosv5.url"), 60, 60);
  27. $grid->column('img_2', '背面图片')->image(config("filesystems.disks.cosv5.url"), 60, 60);
  28. $grid->withBorder();
  29. $grid->model()->orderByDesc("id");
  30. $grid->paginate(10);
  31. $grid->disableActions();
  32. $grid->rowSelector()->titleColumn('name');
  33. //
  34. $grid->filter(function ($filter) {
  35. // 展开过滤器
  36. // $filter->panel();
  37. $filter->expand();
  38. $filter->expand();
  39. $filter->withoutInputBorder();
  40. // 在这里添加字段过滤器
  41. // $filter->equal('id')->width(2);
  42. $filter->equal('name', '名称')->width(3);
  43. $filter->equal('cate', '类别')->select($this->cates)->width(3);
  44. $filter->equal('level', '等级')->select($this->levels)->width(3);
  45. });
  46. });
  47. }
  48. }