Looking to hire Laravel developers? Try LaraJobs

laravel-comments-service maintained by balaremember

Description
Tree comments system for laravel projects
Last update
2018/08/30 10:33 (dev-master)
License
Downloads
1

Comments
comments powered by Disqus

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