PHP code example of bishalgurung / laravel-comment
1. Go to this page and download the library: Download bishalgurung/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/ */
bishalgurung / laravel-comment example snippets
return [
"reactions" => [
"like",
"love",
"dislike",
"wow"
]
];
use BishalGurung\Comment\Traits\HasComments;
class Post extends Model
{
use HasComments;
}
$post = Post::find(1);
$post->addComment("Hey there, this is how you add a comment");
$post->setCommentUser($user)->addComment("Hey there, this is how you add a comment but set the user manually");
$post = Post::find(1);
return $post->getComments(int $pagination_limit, bool $with_reaction_count);
use BishalGurung\Comment\Traits\HasReaction;
class Post extends Model
{
use HasReaction;
}
$post = Post::find(1);
$post->react($reaction_type_id); // The primary key i.e. "id" from reaction_types table
$posts = Post::with("reactionCount")->get();
$comment = Comment::find(1);
$comment->addComment("This is a reply");
$comment->getComments(int $pagination_limit, bool $with_reaction_count);
bash
php artisan vendor:publish --provider="BishalGurung\Comment\CommentServiceProvider" --tag="migration"
bash
php artisan migrate
bash
php artisan comment:install
bash
php artisan vendor:publish --provider="BishalGurung\Comment\CommentServiceProvider" --tag="config"