m4riachi/laravel-comment

add comment bloc to your laravel application

0.1.0 2021-12-08 10:15 UTC

This package is auto-updated.

Last update: 2024-05-08 18:19:35 UTC


README

Latest Version on Packagist Total Downloads

This package add a comment block in the page where it is inserted, the comment is linked to a page (link) not to a model.

Example: if you put the tag on the http://toto.com/controller/action the comments will be linked to this url path.

The tag use the bootstrap css for the styling.

Installation

You can install the package via composer:

composer require m4riachi/laravel-comment


You have publish and run the migrations with:

php artisan vendor:publish --provider="M4riachi\LaravelComment\LaravelCommentServiceProvider" --tag=migrations
php artisan migrate


You can publish the config file with:

php artisan vendor:publish --provider="M4riachi\LaravelComment\LaravelCommentServiceProvider" --tag=config

Optional

If you need to make change in the html design the views files with:

php artisan vendor:publish --provider="M4riachi\LaravelComment\LaravelCommentServiceProvider" --tag=views

Usage

For the front side there is two tags to include in the html of the page where you want to add the comment block.

<x-m4-comment-front-bloc  />

This tag will show the comment form and a list of inserted comment on this page.

<x-m4-comment-front-javascript  />

This one will add the javascript needed.


For the back side there is just one tag.

<x-m4-comment-back-list />

This tag need to use it in the back office, will show all the comment inserted with pagination and two action.

  • An action to change the comment status
  • And delete action

####Config file

From the config file you can configure many option.

  • You can set if a guest user can post a comment, if true 2 input will by added to the form (name, email)
'guest-user' => true, //enable guest user to post a comment
  • You can choose the type of post : normal or ajax post. the plugin use axios to execute ajax
'ajax' => [ 
    'enable' => true, //enable ajax post
    'include_axios' => true, // if false you must have axios on your js files
],
  • By default, the status of every new post is pending, and you have to change the status from the backoffice side
'default_status' => 'pending', // there is two options [pending or approved]
  • like in the description the comment tag is linked to an url path /toto/fofo, if you want to link also the url query you have to enable it. /toto/fofo?param=1 will be different to /toto/fofo?param=2
'with_url_query' => false,
  • Set the model user if he is different to \App\Models\User
'with_url_query' => false,
  • The input validator
'input-validator' => [
    'user_name' => ['required', 'string', 'max:192'],
    'user_email' => ['required', 'string', 'email', 'max:192'],
    'comment' => ['required', 'string'],
],
  • If you want to use recaptcha v3 on your form
'recaptcha' => [
    'enable' => false,
    'site-key' => '',
    'secret-key' => '',
    'checked_score' => 0.4
],

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email taoufiq.benmessaoud@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.