muan / laravel-comments
Comments package for Laravel
Installs: 36
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: >=7.0
This package is not auto-updated.
Last update: 2024-05-12 03:57:15 UTC
README
Used for create comments.
Requirements
- "php": ">=7.0"
Install
- Type next command in your terminal:
composer require muan/laravel-comments
- 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, // ... ],
- 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.