/nova-resource-comment

a commenting field for laravel nova

Primary LanguagePHP

Donate

A commenting field for laravel nova

Screenshot

screenshot 1 screenshot 2

Installation

You can install this package in a Laravel app that uses Nova via composer:

composer require anditsung/nova-resource-comment

Next, we need to run migrations. Auto-discovery of this package's service provider helps with that!

php artisan migrate

And lastly, any model that you want to have comments needs the Commentable trait added to it.

use Anditsung\NovaResourceComment\Traits\Commentable;

class Post extends Model
{
    use Commentable;
    
    // ...
}

If you would like to publish the config for this package, run:

php artisan vendor:publish --tag nova-comment

Usage

Simply add the Anditsung\NovaResourceComment\HasManyComment field in your Nova resource:

namespace App\Nova;

use KAnditsung\NovaResourceComment\HasManyComment;

class Post extends Resource
{
    // ...
    
    public function fields(Request $request)
    {
        return [
            // ...
            
            HasManyComment::make(),

            // ...
        ];
    }
}

Nova's default value for per page via relationship is 5. If you like yo set this to a different value, such as 25, use this method

HasManyComment::make()
    ->maxComment(25),

Now you can comment from the detail view of any resource

Sidebar Navigation

Occasionally you may want to hide comments from the sidebar. You can easily do this by setting the respective config value to false. Make sure to first publish the configs.

'available-for-navigation' => false

Credits