1. Go to this page and download the library: Download anil/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/ */
anil / comments example snippets
use Anil\Comments\Commenter;
class User extends Authenticatable
{
use Notifiable, Commenter;
}
use Anil\Comments\Commentable;
class Post extends Model
{
use Commentable;
}
$post->comments(); // all comments
$post->approvedComments(); // only approved
$post->latestComments(5); // 5 most recent
$post->commentsWithReplies(); // top-level + eager-loaded replies
$post->totalComments(); // count
$post->commentsByUser($userId, $commenterType); // filter by user
$post->commentsInDateRange($start, $end); // date range
$post->commentsWithAttributes(['approved' => true]);
$post->commentsWithRelations(['commenter']);
Post::mostCommented(5); // static — top 5 most commented