承接 nirajan/comment 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nirajan/comment

最新稳定版本:1.0.1

Composer 安装命令:

composer require nirajan/comment

包简介

A Laravel package for handling comments

README 文档

README

License: MIT Laravel Version

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
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-18