DistDistributorTable.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Admin\Renderable;
  3. use App\Models\DistAdminDistributor;
  4. use Dcat\Admin\Grid;
  5. use Dcat\Admin\Grid\LazyRenderable;
  6. class DistDistributorTable extends LazyRenderable
  7. {
  8. public function grid(): Grid
  9. {
  10. return Grid::make(new DistAdminDistributor(), function (Grid $grid) {
  11. $grid->column('id');
  12. $grid->column('company_name', 'Company Name');
  13. $grid->column('country', 'Country');
  14. $grid->column('site_name', 'Site Name');
  15. $grid->column('domain_type',admin_trans_label('domain'))->display(function ($domainType) {
  16. $title = "";
  17. if ($domainType == 0) {
  18. $title = $this->secondary_domain;
  19. } else {
  20. $title = $this->custom_domain;
  21. }
  22. return "<span style='color:#586cb1'>$title</span>";
  23. });
  24. //$grid->column('created_at');
  25. //$grid->column('updated_at');
  26. // 指定行选择器选中时显示的值的字段名称
  27. // 指定行选择器选中时显示的值的字段名称
  28. // 指定行选择器选中时显示的值的字段名称
  29. // 如果表格数据中带有 “name”、“title”或“username”字段,则可以不用设置
  30. $grid->rowSelector()->titleColumn('company_name');
  31. $grid->quickSearch(['id', 'company_name', 'level_domain']);
  32. $grid->paginate(10);
  33. $grid->disableActions();
  34. $grid->filter(function (Grid\Filter $filter) {
  35. $filter->like('company_name')->width(4);
  36. $filter->like('level_domain', 'Level Domain')->width(4);
  37. });
  38. $grid->model()->where('enabled', 1);
  39. });
  40. }
  41. }