PHP code example of nutnet / laravel-comments

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

    

nutnet / laravel-comments example snippets


// config/app.php
'providers' => [
    ...
    Nutnet\LaravelComments\ServiceProvider::class,
    ...
];

use Nutnet\LaravelComments\Services\Commenter;
use Nutnet\LaravelComments\Facades\Commenter as CommenterFacade;

// ... some other code

public function comment(Commenter $commenter)
{
    // variant 1
    $commenter->comment($product, 'Test comment', $user, ['meta' => 'test']);
    
    // variant 2, without meta
    $user->comment($product, 'Test comment', $rate);
    
    // variant 3
    CommenterFacade::comment($product, 'Test comment', $user, ['meta' => 'test']);
}

use Nutnet\LaravelComments\Services\Commenter;
use Nutnet\LaravelComments\Facades\Commenter as CommenterFacade;

// ... some other code

public function comment(Commenter $commenter)
{
    // variant 1
    $commenter->commentAsGuest($product, 'Test comment', ['meta' => 'test']);
    
    // variant 2, without meta
    CommenterFacade::commentAsGuest($product, 'Test comment', ['meta' => 'test']);
}