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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固