ptrml/polycomments

Universal comments for Laravel 5+

dev-master 2016-09-15 12:37 UTC

This package is not auto-updated.

Last update: 2025-04-21 18:02:16 UTC


README

Simple hookable commenting system leveraging polymorphic relationships. Early super rudimentary pre-alfa. May change drastically at any time.

##Installation

###Step 1: Backend ####Install via composer:

composer require ptrml/polycomments "dev-master"

####Register the service provider in conf/app.php:

'providers' => [
...
Ptrml\Polycomments\PolycommentsServiceProvider::class,
...
],

####Publish stuff and migrate:

php artisan vendor:publish --tag=polycomments
php artisan migrate

####Implement both the interface and trait on your models:

class Post extends Model implements CommentableInterface
{
    use Commentable;
    ...
}

(Switch the Post model with your own)

###Step 2: Frontend ####Append PolycommentsController.php with your calls (Post is an example model):

class PolycommentsController extends Controller
{
    function commentPost(Request $request,$id)
    {
        Commenter::comment(Post::find($id),$request);
        return redirect("home");
    }
    ...
}

(Switch the Post model with your own) ####Append routes:

Route::post('/polycomments/post/{id}', 'PolycommentsController@commentPost')->name('polycomments.post');

####Add the premade comments block to the views of your model:

@include('polycomments::polycomments',['polycomments_subject'=>$post,'polycomments_route'=>'polycomments.post'])

(polycomments_subject is your models instance, polycomments_route is the named route)

###Step 3: Customization ####Edit views/vendor/polycomments/* for a custom look and feel:


###Enjoy





License

MIT license.