-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathreplies.php
92 lines (88 loc) · 2.88 KB
/
replies.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
<?php
use App\Models\Reply;
return [
'title' => '回复',
'single' => '回复',
'model' => Reply::class,
'columns' => [
'id' => [
'title' => 'ID',
],
'content' => [
'title' => '内容',
'sortable' => false,
'output' => function ($value, $model) {
return '<div style="max-width:220px">' . $value . '</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);
},
],
'topic' => [
'title' => '话题',
'sortable' => false,
'output' => function ($value, $model) {
return '<div style="max-width:260px">' . model_admin_link($model->topic->title, $model->topic) . '</div>';
},
],
'operation' => [
'title' => '管理',
'sortable' => false,
],
],
'edit_fields' => [
'user' => [
'title' => '用户',
'type' => 'relationship',
'name_field' => 'name',
'autocomplete' => true,
'search_fields' => array("CONCAT(id, ' ', name)"),
'options_sort_field' => 'id',
],
'topic' => [
'title' => '话题',
'type' => 'relationship',
'name_field' => 'title',
'autocomplete' => true,
'search_fields' => array("CONCAT(id, ' ', title)"),
'options_sort_field' => 'id',
],
'content' => [
'title' => '回复内容',
'type' => 'textarea',
],
],
'filters' => [
'user' => [
'title' => '用户',
'type' => 'relationship',
'name_field' => 'name',
'autocomplete' => true,
'search_fields' => array("CONCAT(id, ' ', name)"),
'options_sort_field' => 'id',
],
'topic' => [
'title' => '话题',
'type' => 'relationship',
'name_field' => 'title',
'autocomplete' => true,
'search_fields' => array("CONCAT(id, ' ', title)"),
'options_sort_field' => 'id',
],
'content' => [
'title' => '回复内容',
],
],
'rules' => [
'content' => 'required'
],
'messages' => [
'content.required' => '请填写回复内容',
],
];