PHP code example of byrcsc / laravel-comments

1. Go to this page and download the library: Download byrcsc/laravel-comments library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

byrcsc / laravel-comments example snippets


use ByRcsc\LaravelComments\Concerns\HasComments;

class Post extends Model
{
    use HasComments;
}

$comment = $post->comment('Great write-up!', by: $user);

$reply = $comment->reply('Agreed, especially the last section.', by: $teammate);

$comment->react('👍', by: $teammate);

$guest = $post->commentAsGuest(
    'Where can I download the slides?',
    name: 'Jane',
    email: '[email protected]',
);

$guest->approve(by: $moderator);

$post->comments()->approved()->topLevel()->with('replies')->get();
bash
composer vendor:publish --tag="comments-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="comments-config"
bash
php artisan vendor:publish --tag="comments-translations"
php artisan vendor:publish --tag="comments-views"