LaravelPackages.net
Acme Inc.
Toggle sidebar
balaremember/laravel-comments-service

Tree comments system for laravel projects

1
3
About balaremember/laravel-comments-service

balaremember/laravel-comments-service is a Laravel package for tree comments system for laravel projects. It currently has 3 GitHub stars and 1 downloads on Packagist. Install it with composer require balaremember/laravel-comments-service. Discover more Laravel packages by balaremember or browse all Laravel packages to compare alternatives.

Last updated

Laravel comments

Tree comments system for laravel projects.

Installation

  1. Add the next git repository definition into your composer.json file:

    "repositories": [
        ...
        {
            "type": "vcs",
            "url": "https://github.com/balaremember/laravel-comments-service"
        }
        ...
    ]
    
  2. Run composer install:

    composer require balaremember/laravel-comments-service
    
  3. Laravel

    >= laravel5.5

    ServiceProvider will be attached automatically

    Other

    In your config/app.php add Balaremember\LaravelCommentsService\CommentsServiceProvider::class to the end of the providers array:

    'providers' => [
        ...
        Balaremember\LaravelCommentsService\CommentsServiceProvider::class,
    ],
    

    If Lumen

    $app->register(Balaremember\LaravelCommentsService\CommentsServiceProvider::class);
    

    Publish Configuration

    php artisan vendor:publish --provider "Balaremember\LaravelCommentsService\CommentsServiceProvider"
    
  4. 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

  5. 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

Star History Chart