Package Data | |
---|---|
Maintainer Username: | finagin |
Maintainer Contact: | Igor@Finag.in (Igor Finagin) |
Package Create Date: | 2017-06-16 |
Package Last Update: | 2017-06-29 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-13 15:01:23 |
Package Statistics | |
---|---|
Total Downloads: | 29 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 3 |
Total Forks: | 2 |
Total Open Issues: | 0 |
This package can be used in Laravel 5.4 or higher. You can install the package via composer:
composer require finagin/laravel-comment
Now add the service provider in config/app.php file:
'providers' => [
/*
* Package Service Providers...
*/
// ...
Finagin\Comment\CommentServiceProvider::class,
// ...
];
You must publish the migration with:
php artisan vendor:publish --provider="Finagin\Comment\CommentServiceProvider" --tag="migrations"
After the migration has been published you must create the settings-tables by running the migrations:
php artisan migrate
Also you can publish the config file with:
php artisan vendor:publish --provider="Finagin\Comment\CommentServiceProvider" --tag="config"
Add CanComment
trait to your User model.
use Finagin\Comment\Traits\CanComment;
Add Commentable
trait to your commentable model(s).
use Finagin\Comment\Traits\Commentable;
If you want to have your own Comment Model create a new one and extend my Comment model.
class Comment extends Finagin\Comment\Models\Comment
{
...
}
Comment package comes with several modes.
canBeRated
to true in your Commentable
model.class Post extends Model {
use Commentable;
protected $canBeRated = true;
...
}
mustBeApproved
to true in your Commentable
model.class Post extends Model {
use Commentable;
protected $mustBeApproved = true;
...
}
$user = App\User::find(1);
$post = App\Post::find(1);
// CanComment->comment(Commentable|Commnet $commentable, string $commentText): Comment
// Anonimous first level comment
$comment = (new User(['name' => 'Anonymous']))->comment($post, 'Lorem ipsum ..');
// Users sub comment
$user
->comment($comment, 'Lorem ipsum ..');
// Anonimous sub comment
(new User(['name' => 'Anonymous']))
->comment($comment, 'Lorem ipsum ..');
The MIT License (MIT). Please see License File for more information.