项目作者: risul3

项目描述 :
Ajax based site wide like and commenting system for laravel.
高级语言: PHP
项目地址: git://github.com/risul3/laravel-like-comment.git
创建时间: 2016-08-25T17:32:55Z
项目社区:https://github.com/risul3/laravel-like-comment

开源协议:MIT License

下载


Latest Stable Version
Total Downloads
License

Laravel like comment

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

Try it

Watch

Installation

Run

  1. composer require risul/laravel-like-comment

Configuration

Add

  1. risul\LaravelLikeComment\LikeCommentServiceProvider::class

in your service providerr list.

To copy views and migrations run

  1. php artisan vendor:publish

Run

  1. php artisan migrate

It will create like and comment table.

Add this style links to your view head

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

Add jquery and script

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

In config/laravelLikeComment.php add user model path

  1. 'userModel' => 'App\User'

Add following code in your user model

  1. /**
  2. * Return the user attributes.
  3. * @return array
  4. */
  5. public static function getAuthor($id)
  6. {
  7. $user = self::find($id);
  8. return [
  9. 'id' => $user->id,
  10. 'name' => $user->name,
  11. 'email' => $user->email,
  12. 'url' => '', // Optional
  13. 'avatar' => 'gravatar', // Default avatar
  14. 'admin' => $user->role === 'admin', // bool
  15. ];
  16. }

Usage

Add this line at where you want to integrate Like

  1. @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

  1. @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