sudo/comment

评论 Sudo 包

2.2.3 2020-10-07 06:53 UTC

This package is auto-updated.

Last update: 2024-09-05 05:21:03 UTC


README

介绍: 这是一个用于管理 SudoCms 评论的包。

默认情况下,包将在 /{admin_dir}/comments 创建管理界面,其中 admin_dir 是在 config('app.admin_dir') 中设置的 admin 路径。

安装以使用

  • 包需要具备 base sudo/core 才能正常运行,避免出错
  • 为了使用该包,需要按照以下命令 require:composer require sudo/comment
  • 运行 php artisan migrate 以创建为包服务的表格

发布

默认情况下,运行 php artisan sudo/core 已经为该包生成了内容,但在某些情况下,如果只想单独为该包创建内容,则可以运行以下函数

  • 根据 core 初始化
    • 创建配置:php artisan vendor:publish --tag=sudo/core
    • 仅创建配置:php artisan vendor:publish --tag=sudo/core/config
    • 仅创建资源:php artisan vendor:publish --tag=sudo/core/asset
    • 仅创建视图:php artisan vendor:publish --tag=sudo/core/view
  • 根据 package 初始化
    • 创建配置:php artisan vendor:publish --tag=sudo/comment
    • 仅创建配置:php artisan vendor:publish --tag=sudo/comment/config
    • 仅创建资源:php artisan vendor:publish --tag=sudo/comment/asset
    • 仅创建视图:php artisan vendor:publish --tag=sudo/comment/view

在菜单中进行配置

[
	'type' 		=> 'single',
	'name' 		=> 'Bình luận',
	'icon' 		=> 'fas fa-comments',
	'route' 	=> 'admin.comments.index',
	'role'		=> 'comments_index'
],
  • 配置位置在 config/SudoMenu.php
  • 为了在菜单中显示,可以将上述配置放置在 config('SudoMenu.menu')

在模块中进行配置

'comments' => [
	'name' 			=> 'Bình luận',
	'permision' 	=> [
		[ 'type' => 'index', 'name' => 'Truy cập' ],
		[ 'type' => 'create', 'name' => 'Thêm' ],
		[ 'type' => 'edit', 'name' => 'Sửa' ],
		[ 'type' => 'restore', 'name' => 'Lấy lại' ],
		[ 'type' => 'delete', 'name' => 'Xóa' ],
	],
],
  • 配置位置在 config/SudoModule.php
  • 为了进行权限分配,可以将上述配置放置在 config('SudoModule.modules')

使用方法

包含以下视图,以在所需位置嵌入评论

@include('Comment::list', [
	'type' => 'posts',
	'type_id' => 1,
	'regulation_link' => '#',
	'no_comment_text' => 'Hãy để lại bình luận của bạn tại đây!'
])

其中

  • type: 是表名,也是模块名
  • type_id: 是表 id
  • regulation_link: 到 评论规定 页面的链接
  • no_comment_text: 当没有评论时将显示此文本

访问 config/SudoComment.php(发布后)以获取其他支持的值。