Skip to content

Ajax based site wide like and commenting system for laravel.

License

Notifications You must be signed in to change notification settings

daniloesser/laravel-like-comment

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#laravel-like-comment

Latest Stable Version Total Downloads License

laravel-like-comment is an ajax based like and commenting system for laravel. Which can be used with anything like page, image, post, video etc. User needs to be loged in to be able to like or comment.

Features

  • Like
  • Dislike
  • Comment
  • Comment voting
  • User avatar in comment

Demo

https://www.youtube.com/watch?v=06kcpsnN-bo

Installation

Run

composer require risul/laravel-like-comment

Configuration

Add

risul\LaravelLikeComment\LikeCommentServiceProvider::class

in your service providerr list.

To copy views and migrations run

php artisan vendor:publish

Run

php artisan migrate

It will create like and comment table.

Add this style links to your view head

    <link href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.2/components/icon.min.css" rel="stylesheet">
    <link href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.2/components/comment.min.css" rel="stylesheet">
    <link href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.2/components/form.min.css" rel="stylesheet">
    <link href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.2/components/button.min.css" rel="stylesheet">
    <link href="{{ asset('/vendor/laravelLikeComment/css/style.css') }}" rel="stylesheet">

Add jquery and script

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
    <script src="{{ asset('/vendor/laravelLikeComment/js/script.js') }}" type="text/javascript"></script>

In config/laravelLikeComment.php add user model path

'userModel' => 'App\User'

Add following code in your user model

    /**
     * Return the user attributes.

     * @return array
     */
    public static function getAuthor($id)
    {
        $user = self::find($id);
        return [
            'id'     => $user->id,
            'name'   => $user->name,
            'email'  => $user->email,
            'url'    => '',  // Optional
            'avatar' => 'gravatar',  // Default avatar
            'admin'  => $user->role === 'admin', // bool
        ];
    }

Usage

Add this line at where you want to integrate Like

@include('laravelLikeComment::like', ['like_item_id' => 'image_31'])

like_item_id: This is the id of the item,page or model for which the like will be used

Add this line where you want to integrate Comment

@include('laravelLikeComment::comment', ['comment_item_id' => 'video_12'])

comment_item_id: This is the id of the item, page, or model for which the comment will be used

About

Ajax based site wide like and commenting system for laravel.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 62.2%
  • HTML 22.2%
  • JavaScript 14.7%
  • CSS 0.9%