TemplateTable.php
1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* Created by PhpStorm.
* User: lishuai
* Date: 2022/1/10
* Time: 5:57 PM
*/
namespace App\Admin\Renderable;
use App\Models\VideoTemp;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;
use Dcat\Admin\Widgets\Table;
class TemplateTable extends LazyRenderable
{
public function grid(): Grid
{
return Grid::make(new VideoTemp(), function (Grid $grid) {
$grid->model()->with(['componentsTable'])->where("state",1);
$grid->column('id', 'ID')->sortable();
$grid->column('title');
$grid->column('','组件信息')
->display('展开')
->expand(function (){
$th = ['id','模板id','名称','位置','字号','文字颜色','文字效果','fade时间','背景色','透明度','背景厚度'];
return Table::make($th, $this->componentsTable->toArray())->withBorder();
});
$grid->column('state')->switch();
$grid->quickSearch(['title']);
$grid->paginate(10);
$grid->disableActions();
$grid->filter(function (Grid\Filter $filter) {
$filter->like('title')->width(3);
$filter->like('author')->width(3);
$filter->like('content')->width(3);
});
});
}
}