PHP code example of fbf / laravel-comments

1. Go to this page and download the library: Download fbf/laravel-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/ */

    

fbf / laravel-comments example snippets


/**
 * Defines the polymophic hasMany / morphMany relationship between Post and Comment
 *
 * @return mixed
 */
public function comments()
{
    return $this->morphMany('Fbf\LaravelComments\Comment', 'commentable');
}

@

{{-- Lazy eager load the user data for each comment, this is for --}}
{{-- performance reasons to mitigate against the n+1 query problem --}}
 $comments->load('user'); 

App::bind('Fbf\LaravelComments\CommentsController', function() {
    return new Fbf\LaravelComments\CommentsController(new Comment);
});



class Comment extends Fbf\LaravelComments\Comment {

	public static function boot()
	{
		parent::boot();

		static::creating(function($comment)
		{
			$apiKey = Config::get('webpurify.api_key');
			$webPurifyText = new WebPurify\WebPurifyText($apiKey);
			$comment->comment = $webPurifyText->replace($comment->comment);
		});

	}

}

App::bind('Fbf\LaravelComments\CommentsController', function() {
    return new Fbf\LaravelComments\CommentsController(new Comment);
});



return array(
	'api_key' => 'your_api_key_goes_here',
);