samankhdev / lara-comment
Comment package for laravel +Searchable
v1.3.1
2021-10-15 13:33 UTC
Requires
- nicolaslopezj/searchable: ^1.13
README
this package helps you to add
comment system
for your product,article,...
Installation
composer require samankhdev/lara-comment
Usage
- you should run publish command
php artisan vendor:publish php artisan migrate
- in your model add this method
public function comments() { return $this->morphMany(Comment::class, "commentable"); }
- for showing those comments are parents , do this and also are enable.
public function comments() { return $this->morphMany(Comment::class, "commentable")->where(["answer_id" => 0, 'status' => 1]); }
- for showing children of comment do this if status is true
@foreach ($comment->answers as $answer) {{-- ... --}} @endforeach
- Showing all Answers
@foreach ($comment->allAnswers as $answer) {{-- ... --}} @endforeach
- Show the parent of Comment
$comment->parent;
- Show past time since comment was made.
<span>{{ $comment->ago }}</spaan>