DistDistributorTable.php 1.8 KB

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