rockbuzz / lara-comments
Comments is a package for managing comments on features like Posts
9.0.0
2024-07-27 15:49 UTC
Requires
- php: >=8.1
- bensampo/laravel-enum: ^6.0
Requires (Dev)
- orchestra/testbench: ^7.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-10-31 11:48:44 UTC
README
Comments is a package for managing comments on features like Posts
Requirements
PHP >=7.3
Install
$ composer require rockbuzz/lara-comments
php artisan vendor:publish --provider="Rockbuzz\LaraComments\ServiceProvider"
php artisan migrate
Add the Commenter and Commentable
trait in models for:
use Rockbuzz\LaraComments\Traits\{Commentable, Commenter}; class User extends Authenticatable { use Commenter; } class Post extends Model { use Commentable; }
Usage
User
$user->comments(): HasMany; $user->commentOn(Model $commentable, string $body, string $title = null): Comment; $user->likes(): BelongsToMany; $user->likeTo(Comment $comment): void; $user->dislikeTo(Comment $comment): void;
Post
$post->comments(): MorphMany; $post->hasComments(): bool; $post->asPending($comment): void; $post->approve($comment): void; $post->unapprove($comment): void;
Comment
$comment->commenter(): BelongsTo; $comment->commentable(): MorphTo; $comment->children(): HasMany; $comment->parent(): BelongsTo $comment->isPending(): bool; $comment->isApprove(): bool; $comment->isUnapprove(): bool;
Scope
Comment::approved(); Comment::pending(); Comment::unapproved();
Events
\Rockbuzz\LaraComments\Events\AsPendingEvent::class; \Rockbuzz\LaraComments\Events\ApprovedEvent::class; \Rockbuzz\LaraComments\Events\UnapprovedEvent::class;
License
The Lara Comments is open-sourced software licensed under the MIT license.