forked from summerblue/larabbs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60111c2
commit e12ada1
Showing
6 changed files
with
300 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,11 @@ | |
'roles', | ||
'permissions', | ||
], | ||
'内容管理' => [ | ||
'categories', | ||
'topics', | ||
'replies', | ||
], | ||
], | ||
|
||
/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
use App\Models\Category; | ||
|
||
return [ | ||
'title' => '分类', | ||
'single' => '分类', | ||
'model' => Category::class, | ||
|
||
// 对 CRUD 动作的单独权限控制,其他动作不指定默认为通过 | ||
'action_permissions' => [ | ||
// 删除权限控制 | ||
'delete' => function () { | ||
// 只有站长才能删除话题分类 | ||
return Auth::user()->hasRole('Founder'); | ||
}, | ||
], | ||
|
||
'columns' => [ | ||
'id' => [ | ||
'title' => 'ID', | ||
], | ||
'name' => [ | ||
'title' => '名称', | ||
'sortable' => false, | ||
], | ||
'description' => [ | ||
'title' => '描述', | ||
'sortable' => false, | ||
], | ||
'operation' => [ | ||
'title' => '管理', | ||
'sortable' => false, | ||
], | ||
], | ||
'edit_fields' => [ | ||
'name' => [ | ||
'title' => '名称', | ||
], | ||
'description' => [ | ||
'title' => '描述', | ||
'type' => 'textarea', | ||
], | ||
], | ||
'filters' => [ | ||
'id' => [ | ||
'title' => '分类 ID', | ||
], | ||
'name' => [ | ||
'title' => '名称', | ||
], | ||
'description' => [ | ||
'title' => '描述', | ||
], | ||
], | ||
'rules' => [ | ||
'name' => 'required|min:1|unique:categories' | ||
], | ||
'messages' => [ | ||
'name.unique' => '分类名在数据库里有重复,请选用其他名称。', | ||
'name.required' => '请确保名字至少一个字符以上', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
}, | ||
], | ||
'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' => '请填写回复内容', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
}, | ||
], | ||
'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' => '请填写标题', | ||
], | ||
]; |