PHP code example of itmosoft / laravel-comments

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

    

itmosoft / laravel-comments example snippets


use ItmoSoft\Comments\Concerns\HasComments;

class Post extends Model
{
    use HasComments;
}

use ItmoSoft\Comments\CommentManager;

$manager = app(CommentManager::class);

$comment = $manager->create(
    commentable: $post,
    author: auth()->user(),
    body: 'This looks good.',
);

$reply = $manager->create(
    commentable: $post,
    author: auth()->user(),
    body: 'Thanks!',
    parentId: $comment->id,
);

$manager->update($comment, auth()->user(), 'Updated comment.');
$manager->delete($comment, auth()->user());

$post->comments()->with(['author', 'replies.author'])->latest()->get();
$post->allComments()->public()->get();
$post->allComments()->internal()->get();
bash
composer vendor:publish --tag=itmosoft-comments-config
php artisan migrate