Download the PHP package alayubi/laravel-comment without Composer

On this page you can find all versions of the php package alayubi/laravel-comment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-comment

Instalation

you must publish the migration with:

and rerun the migration.

Config

You can publish the config file with:

Usage

Commentable

If you want a model can be commented you can implements \Lara\Comment\Contracts\IsCommentable interface and add \Lara\Comment\Commentable trait for the implementation.

Commentator

Commentator is a model that comment on a model. Implements \Lara\Comment\Contracts\IsCommentator\ interface on a model if you want to your model to be a commentator and add \Lara\Comment\Commentator trait for the implementation.

Creating Comments

To create a comment to a model you should first create the view with form.

at least you provide the textarea tag HTML with comment name. Then you may create a route to handle the request. In your controller you can use \Lara\Comment\CommentService class and store method to create a comment.

Updating comment

Destory comment

Frontend

Before you start with the default frontend you must integrate your app with:

  1. vue
  2. tailwindcss

The command below will publish the nested comment frontend. With nested comment you can reply a comment. You can publish the frotend with:

it will create views in resources/views/vendor/comment and vue component in resources/js/components/comment directory. Don't forget to copy this code below to your app.js.

After published you are be able to customise the css to fit with your view. To use the frontend nested comment you may include it in your view and pass the commentable model to it.

The code will render the comments with nested indentation belongs to $post. Change the indentation in config file so that you can reply a comment in more deeper indentation. You can imagine the indentation like:

Routes

By default there are three routes for common task.

  1. create visit route('comments.comments.store') or /comments/{comment}/comments with POST method to create a comment on the comment.
  2. update visit route('comments.update') or /comments/{comment} with PUT method to update the comment.
  3. destroy visit route('comments.destroy') or /comments/{comment} with DELETE method to remove the comment from storage.

If you don't want to use the default route put false value in route inside setting file comment.php.

Validation Rule and Requested Data

\Lara\Comment\Validation\DefaultValidator is the default validator. Validator is a class that responsible to get and validate the data from user.

If you want to chnage default behavior of validation or what kind of data you will store to storage you can extends \Lara\Comment\Validation\Validator abstract class then you must implement public function data() and public function rules(). From the class you can access commentator model and request object.

data()

The data function is resposible to return what kind of data to store.

rules()

The rules function is responsible to define what kind of validation rules to run.

Don't forget to change the config validator value to your implementation.

validateWithBag() method

If you have multiple form for comment then you want to display error message You can use validateWithBag() method to validate with bag.

so whene validation error occur you may the access the error bag

you can access the name error bag with combination of the commentable id and the method PUT and POST

Redirector

Redirector will redirect to the URL if validation fails. The default redirector is \Lara\Comment\Redirect\RedirectBack. This will redirect back with URL fragment #validation-comment-error. If you wish to change this default behavior you could create your own redirect by extends \Lara\Comment\Redirect\Redirect abstract class and change the redirector value on configuration comment file to your own implementation.

Policy

You can create your own policy to authorize the action. To create policy class just run the laravel artisan command. For the complete guide see laravel documentation.

Don't forget to change policy class in config file.


All versions of laravel-comment with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package alayubi/laravel-comment contains the following files

Loading the files please wait ....