balaremember / laravel-comments-service
Tree comments system for laravel projects
dev-master
2018-08-30 08:33 UTC
Requires
- php: >=7.1.0
- illuminate/config: ~5.0
- illuminate/container: ~5.0
- illuminate/contracts: ~5.0
- illuminate/database: ~5.0
- illuminate/http: ~5.0
- illuminate/support: ~5.0
Requires (Dev)
- mockery/mockery: 0.9.*
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-05-18 12:32:37 UTC
README
Tree comments system for laravel projects.
Installation
-
Add the next git repository definition into your composer.json file:
"repositories": [ ... { "type": "vcs", "url": "https://github.com/balaremember/laravel-comments-service" } ... ]
-
Run composer install:
composer require balaremember/laravel-comments-service
-
Laravel
>= laravel5.5
ServiceProvider will be attached automatically
Other
In your
config/app.php
addBalaremember\LaravelCommentsService\CommentsServiceProvider::class
to the end of theproviders
array:'providers' => [ ... Balaremember\LaravelCommentsService\CommentsServiceProvider::class, ],
If Lumen
$app->register(Balaremember\LaravelCommentsService\CommentsServiceProvider::class);
Publish Configuration
php artisan vendor:publish --provider "Balaremember\LaravelCommentsService\CommentsServiceProvider"
-
Now you have comments config file with parameters:
'userModel' => Path to your user model, (default: App\User) 'perPage' => Number of comments on one page, (default: 10) 'levelDepth' => Depth of nesting. (default: 3)
Full description of the config variables
-
Custom Polymorphic Types in your AppServiceProvider like:
- To connect comments to your model you need:
class YourModel extends Model { public function comments() { return $this->morphMany(Balaremember\LaravelCommentsService\Entities\Comment::class, 'commentable'); } }
- By default, Laravel will use the fully qualified class name to store the type of the related model. However, you may wish to decouple your database from your application's internal structure.
use Illuminate\Database\Eloquent\Relations\Relation; Relation::morphMap([ 'posts' => 'App\Post', 'videos' => 'App\Video', ]);
See more in Laravel Documentation