### Install Comments for Laravel via Composer and Publish Migrations Source: https://github.com/roundly-consulting/comments-for-laravel/blob/main/README.md Run these commands to install the package and publish its migrations. The second publish command adds tables for likes, reports, approvals, and media packages. Set COMMENTS_KEY_TYPE before migrating if your models use UUID/ULID keys. ```bash composer require roundly-consulting/comments-for-laravel php artisan vendor:publish --tag="comments-migrations" php artisan vendor:publish --tag="likes-migrations" --tag="reports-migrations" --tag="approvals-migrations" --tag="media-migrations" php artisan migrate ``` -------------------------------- ### Add HasComments and GivesComments Traits to Models Source: https://github.com/roundly-consulting/comments-for-laravel/blob/main/README.md Use HasComments on models that receive comments and GivesComments on models that write them. This example shows a Post model receiving comments and a User model giving them. ```php use Illuminate\Database\Eloquent\Model; use RoundlyConsulting\Comments\Traits\GivesComments; use RoundlyConsulting\Comments\Traits\HasComments; class Post extends Model { use HasComments; } class User extends Model { use GivesComments; } ``` -------------------------------- ### Post, Reply, Read, and Moderate Comments via Comments Facade Source: https://github.com/roundly-consulting/comments-for-laravel/blob/main/README.md Use the Comments facade to post a comment, reply to a comment, retrieve the public thread, approve pending comments, and lock comments on a post. The threadedComments method returns approved comments and replies. ```php use RoundlyConsulting\Comments\Facades\Comments; $comment = Comments::on($post)->as($user)->body('Nice write-up!')->post(); Comments::on($post)->as($author)->reply($comment)->body('Thanks!')->post(); // a threaded reply $post->threadedComments()->get(); // the public thread: approved comments + replies Comments::for($post)->pending()->approveAll(); // moderate everything held for review Comments::lock($post); // no new comments on this post ```