FontTable.php
2.12 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* Created by PhpStorm.
* User: lishuai
* Date: 2022/1/10
* Time: 5:57 PM
*/
namespace App\Admin\Renderable;
use App\Admin\Repositories\OnePoem;
use App\Models\Font;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;
use Illuminate\Support\Facades\Storage;
class FontTable extends LazyRenderable
{
public function grid(): Grid
{
return Grid::make(new Font(), function (Grid $grid) {
$grid->paginate(10);
$grid->disableActions();
$grid->quickSearch(['name']);
$grid->column('id')->sortable();
$grid->column('name');
$grid->column('file','字体')->display(function ($item){
$url = Storage::disk('public')->url($item);
return "<style>
@font-face {
font-family: 'ParlandoFont{$this->id}';
src: url('{$url}') format('truetype');
font-weight: normal;
font-style: normal;
}
.mfont-{$this->id}{
font-family: 'ParlandoFont{$this->id}';
color: red;
}
</style><span class='mfont-{$this->id} fa-2x'>字体示例:这里是临境有感</span>";
});
$grid->column('created_at');
$grid->column('updated_at')->sortable();
$grid->filter(function (Grid\Filter $filter) {
$filter->like('name','名称');
});
});
}
// public function grid(): Grid
// {
// return Grid::make(new OnePoem(), function (Grid $grid) {
// $grid->column('id', 'ID')->sortable();
// $grid->column('title');
// $grid->column('author');
// $grid->column('content');
// $grid->column('annotate');
//// $grid->column('spelling');
//// $grid->column('en');
//
// $grid->quickSearch(['title', 'author', 'content', 'annotate']);
//
// $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);
// });
// });
}