Laravel EnsoLaravel Enso
Guide
Back End
Front End
GitHub
Guide
Back End
Front End
GitHub
  • Back End

    • Action Logger
    • Addresses
    • Algolia
    • Algolia Webshop
    • API
    • Audits
    • Avatars
    • Cache Chain
    • Calendar
    • Cargo Partner
    • Categories
    • Charts
    • CI/CD
    • Cli
    • CNP Validator
    • Comments
    • Commercial
    • Companies
    • Core
    • Countries
    • Currencies
    • Data Export
    • Data Import
    • Discounts
    • Documents
    • Dynamic Methods
    • EAV
    • Emag
    • Enums
    • Excel
    • Facebook
    • Files
    • Filters
    • Financials
    • Forms
    • Frisbo
    • Google
    • Helpers
    • Holidays
    • How-to
    • Image Transformer
    • Impersonate
    • Interactions
    • Inventory
    • IO
    • Localisation
    • Lockable Models
    • Logs
    • Measurement Units
    • Meili Search
    • Meili Search Webshop
    • Menus
    • Migrator
    • Monitored Emails
    • Notifications
    • Packaging Units
    • PDF
    • People
    • Permissions
    • Product Eav
    • Product Lots
    • Products
    • Questionnaires
    • Rememberable
    • Roles
    • Sale Channels
    • Searchable
    • Select
    • Sentry
    • Services
    • Smart Bill
    • Sms Advert
    • Stripe
    • Tables
    • Tasks
    • Teams
    • Ticketing
    • Track Who
    • Tutorials
    • Typesense
    • Typesense Webshop
    • Unit Conversion
    • Upgrade
    • UPS
    • User Groups
    • Users
    • Versions
    • Virtual Call Center
    • Vouchers
    • Webshop
    • Webshop Commercial

Comments

LicenseStableDownloadsPHPIssuesMerge Requests

Description

Comments adds polymorphic comments and tagged-user notifications to Enso models.

The package exposes a reusable Commentable trait, ships the comments CRUD API used by the backoffice, tracks authorship through Enso audit traits, and supports tagged users through a pivot relation and queued notifications.

Delete behavior is configurable, allowing applications to either cascade comment deletion or block deletion when related comments exist.

Installation

Install the package:

composer require laravel-enso/comments

Run the package migrations:

php artisan migrate

Optional publishes:

php artisan vendor:publish --tag=comments-config
php artisan vendor:publish --tag=comments-mail
php artisan vendor:publish --tag=comments-factory

Default configuration:

return [
    'editableTimeLimit' => 24 * 60 * 60,
    'onDelete' => 'cascade',
    'humanReadableDates' => true,
    'loggableMorph' => [
        'commentable' => [],
    ],
];

Features

  • Polymorphic one-to-one and one-to-many comments through the Commentable trait.
  • Tagged users stored on a pivot table and notified through queued notifications.
  • Comments API with list, create, update, destroy, and user option endpoints.
  • Configurable delete strategy via restrict or cascade.
  • Automatic parent touching for updated commentable records.

Usage

Add the trait to any model that should expose comments:

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

class Post extends Model
{
    use Commentable;
}

Available relationships:

  • comment()
  • comments()

When a model is deleted, the package will either reject the deletion or cascade comment deletion based on enso.comments.onDelete.

Tagged users can be synchronized and notified through the Comment model:

$comment->syncTags($taggedUsers)->notify('/posts/1');

API

HTTP routes

  • GET api/core/comments
  • POST api/core/comments
  • PATCH api/core/comments/{comment}
  • DELETE api/core/comments/{comment}
  • GET api/core/comments/users

Route names:

  • core.comments.index
  • core.comments.store
  • core.comments.update
  • core.comments.destroy
  • core.comments.users

Model surface

LaravelEnso\\Comments\\Models\\Comment

Useful methods:

  • scopeFor(array $params): Builder
  • syncTags(array $taggedUsers)
  • notify(string $path)

Depends On

Required Enso packages:

  • laravel-enso/core ↗
  • laravel-enso/dynamic-methods ↗
  • laravel-enso/helpers ↗
  • laravel-enso/migrator ↗
  • laravel-enso/track-who ↗
  • laravel-enso/users ↗

Companion frontend package:

  • @enso-ui/comments ↗

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

Edit this page on GitHub
Last Updated: 4/20/2026, 3:05:25 PM
Prev
CNP Validator
Next
Commercial