PHP code example of jncinet / laravel-comment

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

    

jncinet / laravel-comment example snippets


// ...
use Jncinet\LaravelComment\Traits\Commenter;

class User extends Authenticatable
{
    use Commenter;
    
    // ...
}

$user = User::find(1);
// 用户所有评论
$user->comments;
// 用户指定模型评论
$user->getCommentItems(Article::class)->get();

// ...
use Jncinet\LaravelComment\Traits\Commentable;

class Article extends Model
{
    use Commentable;
    
    // ...
}

$article = Article::find(1);
// 文章所有评论
$article->comments;
shell
$ php artisan vendor:publish --provider="Jncinet\\LaravelComment\\CommentServiceProvider"