PHP code example of kirschbaum-development / nova-comments

1. Go to this page and download the library: Download kirschbaum-development/nova-comments library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kirschbaum-development / nova-comments example snippets


use KirschbaumDevelopment\NovaComments\Commentable;

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

namespace App\Nova;

use KirschbaumDevelopment\NovaComments\Commenter;

class Post extends Resource
{
    // ...
    
    public function fields(Request $request)
    {
        return [
            // ...
            
            new Commenter(),

            // ...
        ];
    }
}

namespace App\Nova;

use KirschbaumDevelopment\NovaComments\Commenter;

class Post extends Resource
{
    // ...
    
    public function fields(Request $request)
    {
        return [
            // ...
            
            new CommentsPanel(),

            // ...
        ];
    }
}

'available-for-navigation' => false

use KirschbaumDevelopment\NovaComments\Commenter as NovaCommenter;

class Commenter extends NovaCommenter
{
    /**
     * The number of resources to show per page via relationships.
     *
     * @var int
     */
    public static $perPageViaRelationship = 25;
}

Comment::whenCreating(function (Comment $comment) {
    $comment->comment = strip_tags($comment->comment);
});
bash
php artisan migrate
bash
php artisan vendor:publish