mannysoft/laravel-comment
Composer 安装命令:
composer require mannysoft/laravel-comment
包简介
Just another comment system for your awesome Laravel project.
README 文档
README
Just another comment system for your awesome Laravel project.
Version Compatibility
| Laravel | Laravel Comment |
|---|---|
| 5.0.x | 0.1.x |
| 5.1.x | 0.1.x |
| 5.2.x | 0.1.x |
| 5.3.x | 0.2.x |
| 5.4.x | 0.3.x |
For >5.5 you can use ^1.0.0 version.
Install
Via Composer
$ composer require actuallymab/laravel-comment
If you don't use auto-discovery, or using Laravel version < 5.5 Add service provider to your app.php file
\Actuallymab\LaravelComment\LaravelCommentServiceProvider::class
Publish configurations and migrations, then migrate comments table.
$ php artisan vendor:publish $ php artisan migrate
Add CanComment trait to your User model.
use Actuallymab\LaravelComment\CanComment; class User extends Model { use CanComment; // ... }
Add Commentable interface and HasComments trait to your commentable model(s).
use Actuallymab\LaravelComment\Contracts\Commentable; use Actuallymab\LaravelComment\HasComments; class Product extends Model implements Commentable { use HasComments; // ... }
If you want to have your own Comment Model create a new one and extend my Comment model.
use Actuallymab\LaravelComment\Models\Comment as LaravelComment; class Comment extends LaravelComment { // ... }
and dont forget to update the model name in the config/comment.php file.
Comment package comes with several modes.
1- If you want to users can rate your commentable models;
class Product extends Model implements Commentable { use HasComments; public function canBeRated(): bool { return true; // default false } //... }
2- If you want to approve comments for your commentable models;
class Product extends Model implements Commentable { use HasComments; public function mustBeApproved(): bool { return true; // default false } // ... }
3- Sometimes you don't want to approve comments for all users;
class User extends Model { use CanComment; protected $fillable = [ 'isAdmin', // .. ]; public function canCommentWithoutApprove(): bool { return $this->isAdmin; } // .. }
Usage
$user = App\User::first(); $product = App\Product::first(); // $user->comment(Commentable $model, $comment = '', $rate = 0); $user->comment($product, 'Lorem ipsum ..', 3); // approve it -- if the user model `canCommentWithoutApprove()` or you don't use `mustBeApproved()`, it is not necessary $product->comments[0]->approve(); // get avg rating -- it calculates approved average rate. $product->averageRate(); // get total comments count -- it calculates approved comments count. $product->totalCommentsCount();
Tip: You might want to look at the tests/CommentTest.php file to check all potential usages.
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email mehmet.aydin.bahadir@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
mannysoft/laravel-comment 适用场景与选型建议
mannysoft/laravel-comment 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「actuallymab」 「laravel-comment」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mannysoft/laravel-comment 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mannysoft/laravel-comment 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mannysoft/laravel-comment 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Just another comment system for laravel projects.
Laravel comment - Create comments to your Laravel projects
Just another comment system for laravel projects.
Just another comment system for your awesome Laravel project.
A full and simple Toolkit Package for instantly adding Social Features to Laravel Project [Adapted From Miladimos]
Just another comment system for laravel projects.
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-09