-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathtopics.php
105 lines (98 loc) · 3.16 KB
/
topics.php
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
use App\Models\Topic;
return [
'title' => '话题',
'single' => '话题',
'model' => Topic::class,
'columns' => [
'id' => [
'title' => 'ID',
],
'title' => [
'title' => '话题',
'sortable' => false,
'output' => function ($value, $model) {
return '<div style="max-width:260px">' . model_link($value, $model) . '</div>';
},
],
'user' => [
'title' => '作者',
'sortable' => false,
'output' => function ($value, $model) {
$avatar = $model->user->avatar;
$value = empty($avatar) ? 'N/A' : '<img src="'.$avatar.'" style="height:22px;width:22px"> ' . $model->user->name;
return model_link($value, $model->user);
},
],
'category' => [
'title' => '分类',
'sortable' => false,
'output' => function ($value, $model) {
return model_admin_link($model->category->name, $model->category);
},
],
'reply_count' => [
'title' => '评论',
],
'operation' => [
'title' => '管理',
'sortable' => false,
],
],
'edit_fields' => [
'title' => [
'title' => '标题',
],
'user' => [
'title' => '用户',
'type' => 'relationship',
'name_field' => 'name',
// 自动补全,对于大数据量的对应关系,推荐开启自动补全,
// 可防止一次性加载对系统造成负担
'autocomplete' => true,
// 自动补全的搜索字段
'search_fields' => ["CONCAT(id, ' ', name)"],
// 自动补全排序
'options_sort_field' => 'id',
],
'category' => [
'title' => '分类',
'type' => 'relationship',
'name_field' => 'name',
'search_fields' => ["CONCAT(id, ' ', name)"],
'options_sort_field' => 'id',
],
'reply_count' => [
'title' => '评论',
],
'view_count' => [
'title' => '查看',
],
],
'filters' => [
'id' => [
'title' => '内容 ID',
],
'user' => [
'title' => '用户',
'type' => 'relationship',
'name_field' => 'name',
'autocomplete' => true,
'search_fields' => array("CONCAT(id, ' ', name)"),
'options_sort_field' => 'id',
],
'category' => [
'title' => '分类',
'type' => 'relationship',
'name_field' => 'name',
'search_fields' => array("CONCAT(id, ' ', name)"),
'options_sort_field' => 'id',
],
],
'rules' => [
'title' => 'required'
],
'messages' => [
'title.required' => '请填写标题',
],
];