LaravelPackages.net
Acme Inc.
Toggle sidebar
muan/laravel-comments

Comments package for Laravel

44
2
0.1.0
About muan/laravel-comments

muan/laravel-comments is a Laravel package for comments package for laravel. It currently has 2 GitHub stars and 44 downloads on Packagist (latest version 0.1.0). Install it with composer require muan/laravel-comments. Discover more Laravel packages by muan or browse all Laravel packages to compare alternatives.

Last updated

Maun Laravel Comments package

Maintainability

Used for create comments.

Requirements

  • "php": ">=7.0"

Install

  1. Type next command in your terminal:
composer require muan/laravel-comments
  1. Add the service provider to your config/app.php file in section providers:

Laravel 5.5 uses Package Auto-Discovery, so does not require you to manually add the ServiceProvider.

'providers' => [
    // ...
    Muan\Comments\Providers\CommentsServiceProvider::class,
    // ...
],
  1. Use the following trait on your User model
// Use trait
use Muan\Comments\Traits\CanComment;
 
class User extends Authenticatable
{
    use CanComment;
    
    // ...
}

Add Commentable trait to your commentable model(s).

use Muan\Comments\Traits\Commentable;

Usage

$user = App\User::find(1);
$product = App\Product::find(1);

// Add comment
$comment = $user->addComment($product, 'Lorem ipsum...');

// or
$comment = $product->addComment($user, 'Lorem ipsum...');

// Approve comment
$comment->approve();

// get comments
$comments = $user->comments;

// get comments
$comments = $product->comments;

License

Muan Laravel Admin package is licensed under the MIT License.

Star History Chart