1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Admin\Renderable;
- use App\Admin\Repositories\DistAdminDistributor;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Grid\LazyRenderable;
- class DistDistributorTable extends LazyRenderable
- {
- public function grid(): Grid
- {
- return Grid::make(DistAdminDistributor::with(['appearance']), function (Grid $grid) {
- $grid->column('id');
- $grid->column('company_name', 'Company Name')->width('35%');
- $grid->column('appearance.title' ,admin_trans_field('appearance'));
- $grid->column('country', 'Country');
- $grid->column('site_name', 'Site Name');
- $grid->column('domain_type',admin_trans_label('domain'))->display(function ($domainType) {
- $title = "";
- if ($domainType == 0) {
- $title = $this->secondary_domain;
- } else {
- $title = $this->custom_domain;
- }
- return "<span style='color:#586cb1'>$title</span>";
- });
- //$grid->column('created_at');
- //$grid->column('updated_at');
- // 指定行选择器选中时显示的值的字段名称
- // 指定行选择器选中时显示的值的字段名称
- // 指定行选择器选中时显示的值的字段名称
- // 如果表格数据中带有 “name”、“title”或“username”字段,则可以不用设置
- $grid->rowSelector()->titleColumn('company_name');
- $grid->quickSearch(['company_name']);
- $grid->paginate(10);
- $grid->disableActions();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->like('company_name')->width(4);
- $filter->like('site_name')->width(4);
- });
- $grid->model()->where('enabled', 1);
- });
- }
- }
|