tuananh0907 / packages_comments
Comments and likes for Laravel.
Requires
- php: ^8.0
- erusev/parsedown: ^1.7
- illuminate/database: ^9.0
- illuminate/http: ^9.0
- illuminate/pagination: ^9.0
- illuminate/queue: ^9.0
- illuminate/routing: ^9.0
- illuminate/support: ^9.0
- spatie/laravel-honeypot: ^4.1
README
This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.
Overview
Package này có thể giúp bạn thêm một chức năng nhận xét nhanh chóng cho bất kì model nào của bạn. Tất cả các nhận xét được lưu tại một bảng duy nhất và có liên kết với khách hàng. Chức năng thích và hủy thích cũng được gắn lên từng bình luận. Bạn có thể xem những người đã thích bình luận bằng hành
Installation
You can install the package via composer:
composer require tuananh0907/packages_comments
Features
- View comments
- Create comments
- Delete comments
- Edit comments
- Reply to comments
- Authorization rules
- Support localization
- Dispatch events
- Route, Controller, Comment, Migration & View customizations
- Pagination (opt-in)
- Like comments
- Dislike comments
- View liker
Run migrations
We need to create the table for comments and likes.
php artisan migrate
Add Commenter trait to your User model
Add the Commenter trait to your User model so that you can retrieve the comments for a user:
use Laravelista\Comments\Commentable; class Product extends Model { use Commentable; }
Add Commentable trait to models
Add the Commentable trait to the model for which you want to enable comments for:
use Laravelista\Comments\Commentable; class Product extends Model { use Commentable; }
Publish Config & configure (optional)
Publish the config file (optional):
php artisan vendor:publish --provider="Laravelista\Comments\ServiceProvider" --tag=config
Publish views (customization)
The default UI is made for Bootstrap 4, but you can change it however you want.
php artisan vendor:publish --provider="Laravelista\Comments\ServiceProvider" --tag=views
Publish Migrations (customization)
You can publish migration to allow you to have more control over your table
php artisan vendor:publish --provider="Laravelista\Comments\ServiceProvider" --tag=migrations
Publish translations (customization)
The package currently only supports English, but I am open to PRs for other languages.
php artisan vendor:publish --provider="Laravelista\Comments\ServiceProvider" --tag=translations
Usage
Giao diện sử dụng tailwindcss nên dự án cần cài đặt tailwindcss:
Xem hướng dẫn cài đặt tại đây
Trong giao diện hiển thị bạn muốn gắn thêm phần bình luận, gắn đoạn code sau vào chỗ đó:
Ở đây ví dụ là một bài viết
@comments(['model' => $post])
Để xem bình luận được phê duyệt
@comments([ 'model' => $book, 'approved' => true ])
Phân trang: xác định số lượng nhận xét trên mỗi trang
@comments([ 'model' => $user, 'perPage' => 2 ])
Xác định cấp độ hiển thị của bình luận
@comments([ 'model' => $user, 'maxIndentationLevel' => 1 ])
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email tuananhtybg.99@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
PHP Package Boilerplate
This package was generated using the PHP Package Boilerplate by Beyond Code.