PHP code example of editmode / laravel-comments

1. Go to this page and download the library: Download editmode/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/ */

    

editmode / laravel-comments example snippets


use Nika\LaravelComments\Models\Comment as BaseComment;

        
class Comment extends BaseComment
         ↑
{
    // Add your own relationships, scopes, or overrides here
}

return [
    'model' => App\Models\Comment::class,
];

use Nika\LaravelComments\Traits\HasComments;

class Post extends Model
{
    use HasComments;
}

$post = Post::find(1);

$post->comment('This is a comment from the logged-in user');

$post->commentAsUser($user, 'This is a comment from a specific user');

use Nika\LaravelComments\Models\Comment as BaseComment;
use Nika\LaravelComments\Traits\HasReactions;

class Comment extends BaseComment
{
    use HasReactions;
}

Route::comments();
bash
php artisan vendor:publish --tag=comments-config
bash
php artisan vendor:publish --tag="comments-migrations"
bash
php artisan vendor:publish --tag="comments-config"
bash
php artisan vendor:publish --provider="Nika\LaravelComments\LaravelCommentsServiceProvider" --tag="comments-migrations"
bash
php artisan migrate
bash)

[//]: # (php artisan vendor:publish --tag="laravel-comments-views")

[//]: # (
bash
php artisan route:list --path=comments