nirajan/comment
最新稳定版本:1.0.1
Composer 安装命令:
composer require nirajan/comment
包简介
A Laravel package for handling comments
README 文档
README
A simple, reusable Laravel package to add commenting functionality to any Eloquent model with minimal setup.
Features
- Polymorphic Support: Add comments to any model (Posts, Products, etc.) using a single Trait.
- Blade Components: Includes ready-to-use components for comment forms and lists.
- Admin Dashboard: Built-in management interface at
/AdminActivity/comments. - Security: Integrated ReCAPTCHA validation support.
- Moderation: Optional comment approval system.
- Customizable: Easily configurable middleware, layouts, and routes.
Installation
1. Require the package via Composer
composer require nirajan/comment
2. Publish Configuration and Migrations
php artisan vendor:publish --provider="Nirajan\Comment\CommentServiceProvider"
3. Run Migrations
php artisan migrate
Configuration
After publishing, you can find the configuration file at config/comment.php.
return [ 'admin_middleware' => ['web', 'admin'], 'recaptcha_site_key' => env('RECAPTCHA_SITE_KEY'), 'recaptcha_secret_key'=> env('RECAPTCHA_SECRET_KEY'), 'admin_url_prefix' => 'AdminActivity', 'admin_layout' => 'backend.layouts.master', 'need_approval' => false, 'post_route' => [ 'name' => 'posts.detail', 'param' => 'id', 'callback' => null, ], ];
Usage
1. Prepare your Model
Add the HasComments trait to any model you want to allow comments on.
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Nirajan\Comment\Traits\HasComments; class Post extends Model { use HasComments; }
2. Add Blade Components
Insert the following components into your views (e.g., show.blade.php).
<x-comment::comment-form :model="$post" /> <x-comment::comment-list :model="$post" />
Admin Dashboard
You can manage, delete, and approve comments through the built-in dashboard:
your-domain.com/AdminActivity/comments
Note: Ensure your admin_layout in the config file matches your actual admin theme layout.
License
The MIT License (MIT). Please see the License File for more information.
Contributing
Feel free to submit issues or pull requests to improve this package.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-18