aldawoud / comments
评论分区包
dev-master
2020-10-14 04:25 UTC
This package is not auto-updated.
Last update: 2024-09-22 07:48:16 UTC
README
评论包是一个laravel包,允许用户在设置后对任何其他模型进行评论。
安装
安装包
composer require aldawoud/comments
通过添加以下代码到 web.php
文件中添加路由。
//web.php Comment::routes();
实现
将评论分区ID列添加到您要实现其上的模型。
// 2020_01_01_create_blog_table.php ... public function up() { Schema::create('blogs', function (Blueprint $table) { $table->id(); $table->string("title"); $table->string("content"); $table->string("comment_section_id"); $table->timestamps(); }); } ...
路由
定制
评论回复可以是嵌套的,也可以只做到两层。要更改这一点,您需要首先发布包。
php artisan vendor:publish
输出
Which provider or tag's files would you like to publish?:
选择 Provider: Aldawoud\Comments\CommentsServiceProvider
编号
然后您可以修改评论模型中的 nested
属性,如果希望回复嵌套则为 true,如果希望回复为两层则为 false。
protected static $nested = true;