PHPackages                             nirajan/comment - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nirajan/comment

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nirajan/comment
===============

A Laravel package for handling comments

1.0.2(3w ago)011MITBladePHP ^8.0

Since Mar 18Pushed 3w agoCompare

[ Source](https://github.com/Nirajan14/comment)[ Packagist](https://packagist.org/packages/nirajan/comment)[ RSS](/packages/nirajan-comment/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

Laravel Comment Package
=======================

[](#laravel-comment-package)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![Laravel Version](https://camo.githubusercontent.com/73692ab0f1fac2901149539199fa738ac249d6cd2387048e8063666cfab3d736/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302e7825323025374325323031312e7825323025374325323031322e782d7265642e737667)](https://laravel.com)

A lightweight Laravel package for adding comments to any Eloquent model using polymorphic relationships.

Features
--------

[](#features)

- Polymorphic comment support for any Eloquent model
- Blade components for comment forms and comment lists
- Admin dashboard for moderation, approval, and deletion
- Optional ReCAPTCHA validation support
- Configurable middleware, URL prefix, layout, and approval workflow
- Easy installation and package reuse

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10.x, 11.x, or 12.x

Installation
------------

[](#installation)

1. Install the package via Composer:

```
composer require nirajan/comment
```

2. Publish package resources:

```
php artisan vendor:publish --provider="Nirajan\Comment\CommentServiceProvider"
```

3. Run the migrations:

```
php artisan migrate
```

Configuration
-------------

[](#configuration)

The package publishes a configuration file at `config/comment.php`.

Example configuration:

```
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,
    ],
    'theme' => [
        'icon_button_color' => '#fd0000',
        'icon_button_color_secondary' => '#fd0000',
    ],
];
```

### Important configuration options

[](#important-configuration-options)

- `admin_middleware` - Middleware applied to the admin comment routes
- `admin_url_prefix` - URL prefix used for the dashboard route
- `admin_layout` - Blade layout used by admin views
- `need_approval` - Set to `true` to require manual approval before comments are public
- `post_route` - Redirect options for a comment reply route or detail route

Usage
-----

[](#usage)

### Enable comments on a model

[](#enable-comments-on-a-model)

Add the `HasComments` trait to any model:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Nirajan\Comment\Traits\HasComments;

class Post extends Model
{
    use HasComments;
}
```

### Display the comment form and list

[](#display-the-comment-form-and-list)

Use the provided Blade components in your view:

```

```

### Component props

[](#component-props)

- `comment-form` expects a `model` instance that uses `HasComments`
- `comment-list` expects a `model` instance and displays related comments

Admin Dashboard
---------------

[](#admin-dashboard)

Visit the admin dashboard at:

```
/ AdminActivity/comments

```

The dashboard supports:

- viewing all comments
- approving or rejecting comments
- deleting comments
- filtering by approval status

> Update `admin_url_prefix` and `admin_layout` in `config/comment.php` to match your application.

ReCAPTCHA Support
-----------------

[](#recaptcha-support)

If you want to enable ReCAPTCHA validation, add your keys to `.env`:

```
RECAPTCHA_SITE_KEY=your-site-key
RECAPTCHA_SECRET_KEY=your-secret-key
```

Then update `config/comment.php` accordingly.

Customization
-------------

[](#customization)

You can customize package behavior through `config/comment.php` and by overriding published views in your application if needed.

License
-------

[](#license)

This package is licensed under the MIT License. See the `LICENSE` file for details.

Contributing
------------

[](#contributing)

Contributions, issues, and pull requests are welcome. Please open an issue first if you want to propose a larger change.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance94

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~36 days

Total

3

Last Release

26d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/75e9851a40cf1b4fe1639ba054c01be3f618637878636064bd530dc3ef8acb0b?d=identicon)[nirajanch\_](/maintainers/nirajanch_)

---

Top Contributors

[![Nirajan14](https://avatars.githubusercontent.com/u/74029766?v=4)](https://github.com/Nirajan14 "Nirajan14 (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nirajan-comment/health.svg)

```
[![Health](https://phpackages.com/badges/nirajan-comment/health.svg)](https://phpackages.com/packages/nirajan-comment)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pipeline

The Illuminate Pipeline package.

9348.3M267](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10533.5M989](/packages/illuminate-pagination)[illuminate/redis

The Illuminate Redis package.

8314.4M362](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

224.5M132](/packages/illuminate-cookie)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
