The following tutorial column will introduce you to the use of laravel-like-comment comment plug-in, I hope it will be helpful to friends in need!
Laravel like comment
Function
composer require risul/laravel-like-comment
risul\LaravelLikeComment\LikeCommentServiceProvider::class
php artisan vendor:publish
Migrate the data table Create data tables related to comments.
php artisan migrate
<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">
Note : Because jquery in the original article uses Google resources, I modified it to domestic.
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script> <script src="{{ asset('/vendor/laravelLikeComment/js/script.js') }}" type="text/javascript"></script>
config/laravelLikeComment.php
Note: Be optimistic about your user model path and whether to modify it. The default path is below.
'userModel' => 'App\User'
Use on the page you want to add likes to Add the following code./** * 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 ]; }Copy after login
@include('laravelLikeComment::like', ['like_item_id' => 'image_31'])
For example, I want to display the article in the article post model Add this function to the page and mark it in the data table. The detailed information of this data can be combined and marked post_1 (post is the article model, 1 is the article id). The quote is as follows:
@include('laravelLikeComment::like', ['like_item_id' => "post_".$post->id])
Add the following code in the module where you want to add comments:The marking method is as above
@include('laravelLikeComment::comment', ['comment_item_id' => 'video_12'])
comment_item_id:is the comment tag id of the module to be integrated.
The above is the detailed content of Teach you how to use laravel-like-comment comment plug-in. For more information, please follow other related articles on the PHP Chinese website!