• Reading time ~ 1 min
  • 05.06.2022

Laravel Comments is a premium comments package for applications using PHP 8.1+ and Laravel 9+ by Spatie. Using this package, you can create and associate comments with Eloquent models.

At the time of launch, Laravel Comments' main features include:

  • A beautiful Livewire component to display comments
  • markdown submission is supported, we'll render it as html
  • code snippets that appear in comments will automatically be highlighted
  • users can react to comments (👍, ❤️, or any emoji you want)
  • optionally, you enable a comment approval flow
  • sane API for creating your own commenting UI
  • Livewire components out of the box

At the core of this package is the HasComments trait you'll add to models:

use Illuminate\Database\Eloquent\Model;
use Spatie\Comments\Models\Concerns\HasComments;
 
class Post extends Model
{
    use HasComments;
}

Which then enables you to manage comments and reactions on a model:

$post->comment("I've got a feeling");
 
$comment->react('😍');

While the above is a barebones example, the package also comes with a fully baked Laravel Livewire component, which also supports one level of nested comments:

Note that you must pay for a premium license to use this package. To get started, check out the Laravel Comments documentation.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297