PHPackages                             bellal22/comments - 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. bellal22/comments

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

bellal22/comments
=================

lightweight laravel package to add Comments and reply Features to your application

v1.0.1(1y ago)026MITPHP

Since Feb 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Bellal22/lara-comments)[ Packagist](https://packagist.org/packages/bellal22/comments)[ RSS](/packages/bellal22-comments/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (3)Used By (0)

Comments Package for Laravel
============================

[](#comments-package-for-laravel)

Introduction
------------

[](#introduction)

The **Comments Package** is a powerful and flexible solution for adding comment functionality to any Laravel project. Designed with scalability and ease of use in mind, it integrates seamlessly with Laravel's ecosystem.

This package allows users to add comments to any model in your application with minimal setup. It is ideal for building forums, blogs, ticketing systems, or any other application requiring a robust commenting system.

[![Package Banner](comment-component.jpeg)](comment-component.jpeg)[![Package Banner](new-comment.jpeg)](new-comment.jpeg)

---

Features
--------

[](#features)

- **Eloquent Integration**: Easily attach comments to any model.
- **Soft Deletes**: Handle comment deletion without losing data.
- **Highly Configurable**: Customize behaviors via configuration files.
- **PSR-4 Autoloading**: Easy integration into Laravel projects.

---

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

[](#requirements)

- PHP 8.0+
- Laravel 8.x or later

---

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

[](#installation)

Install the package via Composer:

```
composer require bellal22/comments
```

---

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

[](#configuration)

### Publish Configuration File

[](#publish-configuration-file)

Run the following command to publish the package's configuration file:

```
php artisan vendor:publish --tag=comments-config
php artisan vendor:publish --tag=comments-assets
```

This will create a `config/comments.php` file where you can customize the package's behavior.

### set Configuration

[](#set-configuration)

write your commentables Model classes in config file

```
'commentables' => [
        // Define models that can have comments here
        // Example: 'order' => Order::class,
    ],
```

### Clear Configuration Cache

[](#clear-configuration-cache)

Run the following command to publish the package's configuration file:

```
php artisan config:clear
php artisan cache:clear
```

---

Migrations
----------

[](#migrations)

Publish and run the package's migrations to set up the required database tables:

```
php artisan vendor:publish --tag=comments-migrations
php artisan migrate
```

---

Usage
-----

[](#usage)

### Setting Up Models

[](#setting-up-models)

Add the `Commentable` trait to any model that you want to associate with comments:

```
namespace App\Models;

use Bellal22\Comments\Traits\Commentable;
use Illuminate\Database\Eloquent\Model;

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

### Adding Comments

[](#adding-comments)

You can add a comment to a model instance as follows:

```
use App\Models\Post;
use Bellal22\Comments\Models\Comment;

$post = Post::find(1);
$comment = $post->addComment([
    'user_id' => auth()->id(),
    'content' => 'This is a great post!',
]);
```

### Retrieving Comments

[](#retrieving-comments)

Retrieve all comments associated with a model:

```
$comments = $post->comments;
```

### Delete Comment

[](#delete-comment)

Delete specific Comment:

```
$comments = $post->removeComment($comment);
```

### Other Methods

[](#other-methods)

count all comments related to model:

```
$comments = $post->commentCount();
```

get latest n comments (integer parameter) 5 is default:

```
$comments = $post->latestComments();
```

retrieve comments without replies:

```
$comments = $post->allComments();
```

---

Blade Components
----------------

[](#blade-components)

The package provides ready-to-use Blade components for managing and displaying comments.

### Comment Form

[](#comment-form)

Include the comment form component in your Blade views:

```

```

### Comments List

[](#comments-list)

Render a list of comments:

```

```

---

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

[](#contributing)

Contributions are welcome! Please follow these steps:

1. Fork the repository.
2. Create a new branch for your feature or fix.
3. Submit a pull request with a detailed explanation of your changes.

---

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

---

Author
------

[](#author)

Developed and maintained by **Bellal Hassen**. Connect with me on [GitHub](https://github.com/Bellal22).

---

Acknowledgments
---------------

[](#acknowledgments)

- [Laravel Framework](https://laravel.com)

---

###  Health Score

24

—

LowBetter than 30% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

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 ~0 days

Total

2

Last Release

557d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38460760?v=4)[Bellal Hassen](/maintainers/Bellal22)[@Bellal22](https://github.com/Bellal22)

### Embed Badge

![Health badge](/badges/bellal22-comments/health.svg)

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

###  Alternatives

[jeremykenedy/uuid

Laravel package to generate a UUID according to the RFC 4122 standard. UUID Versions 1, 3, 4 and 5 are supported. With MIT license.

23137.6k](/packages/jeremykenedy-uuid)[tarunkorat/laravel-asset-cleaner

Safely detect and remove unused CSS, JS, SCSS and other assets from Laravel applications

747.3k1](/packages/tarunkorat-laravel-asset-cleaner)[liagkos/vatidinfo

Retrieve greek business iformation from tax registry

175.2k](/packages/liagkos-vatidinfo)

PHPackages © 2026

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