Coder Social home page Coder Social logo

comments's Introduction

Comments for Laravel.

Features

  • Comments and reply Comments
  • Blacklist
  • Moderation Mode
    • Mode => 1 (Public): All comments will be public.
    • Mode => 2 (Review comments on the blacklist): Comments that do not contain blacklisted words will be public. Otherwise, they will remain hidden
    • Mode => 3 (Close): Comments will be created that do not contain blacklisted words. Otherwise, they will not be created
  • Limit comment characters
  • Limit number of links in a comment
  • UrlLinker (convert text links to html)

Installation

From the command line:

composer require wimil/comments

Publish Config & configure

Publish the config file:

php artisan vendor:publish --provider="Wimil\Comments\Provider" --tag=config

Publish Migrations

You can publish migration to allow you to have more control over your table

php artisan vendor:publish --provider="Wimil\Comments\Provider" --tag=migrations

Run migrations

We need to create the table for comments.

php artisan migrate

Add Commenter trait to your Model

Add the Commenter trait to your User model so that you can retrieve the comments for a user:

use Wimil\Comments\Commenter;

class User extends Authenticatable
{
    use Notifiable, Commenter;
}

Add Commentable trait to models

Add the Commentable trait to the model for which you want to enable comments for:

use Wimil\Comments\Commentable;

class Product extends Model
{
    use Commentable;
}

If you want to have your own Comment Model create a new one and extend my Comment model.

use Wimil\Comments\Model\Comment as BaseComment;

class Comment extends BaseComment
{
    // ...
}

and dont forget to update the model name in the config/comment.php file.

Comment package comes with several modes.

Usage

$user = App\User::first();
$product = App\Product::first();

// $user->comment(Commentable $model, $comment = '');
$user->comment($product, 'Lorem ipsum ..');

comments's People

Contributors

wimil avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.