PHP code example of webazin / comment

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

    

webazin / comment example snippets


'providers' => [
    webazin\Comment\CommentServiceProvider::class
];



namespace App;

use webazin\comment\Traits\Commentable as Comment;
use Illuminate\Database\Eloquent\Model;

class Post extends Model implements Comment
{
    use Comment;
}

$user = User::first();
$post = Post::first();

$comment = $post->comment([
    'comment' => 'comment text'
], $user);

dd($comment);

$user = User::first();
$post = Post::first();

$comment = $post->commentUnique([
    'comment' => 'comment text'
], $user);

dd($comment);

$comment = $post->updateComment(1, [
    'comment' => 'comment text'
]);

$post->deleteComment(1);

$post->commentCount

// $post->commentCount() also works for this.
`
php artisan comment:migration
`
php artisan migrate