jafaripur/laravel-comment
Composer 安装命令:
composer require jafaripur/laravel-comment
包简介
Commenting system in laravel
README 文档
README
Persistant, application-wide commenting system for Laravel.
Installation
composer require jafaripur/laravel-comment- Add
jafaripur\LaravelComments\ServiceProviderto the array of providers inconfig/app.php. - Publish the config file by running
php artisan vendor:publish. The config file will give you control over which storage engine to use as well as some storage-specific comments. - Optional: add
'Comments' => 'jafaripur\LaravelComments\Facade'to the array of aliases inconfig/app.php.
Usage
You can either access the comments store via its facade or inject it by type-hinting towards the abstract class jafaripur\LaravelComments\CommentStore.
The read function Closure give field list which want to add to query condition.
<?php Comment::read(function($fields) use ($item){ $fields->namespace = $item['namespace']; $fields->threadId = $item['thread_id']; $fields->parentId = $item['parent_id']; $fields->approved = $item['approved']; $fields->userId = $item['user_id']; }); Comment::save(function($fields) use ($item){ $fields->namespace = $item['namespace']; $fields->threadId = $item['thread_id']; $fields->content = $item['content']; $fields->parentId = $item['parent_id']; $fields->approved = $item['approved']; $fields->userId = $item['user_id']; }); Comment::delete($id); Comment::approve($id); Comment::unapprove($id); ?>
Database storage
Using Migration File
If you use the database store you need to run php artisan migrate --path=vendor/jafaripur/laravel-comment/src/migrations to generate the table.
Example
If you need more fine-tuned control over which data gets queried, you can use the setConstraint method which takes a closure with two arguments:
$queryis the query builder instance$insertis a boolean telling you whether the query is an insert or not. If it is an insert, you usually don't need to do anything to$query.
<?php Comment::setConstraint(function($query, $insert) { if ($insert) return; $query->where(/* ... */); }); ?>
Custom stores
This package uses the Laravel Manager class under the hood, so it's easy to add your own custom session store driver if you want to store in some other way. All you need to do is extend the abstract CommentStore class, implement the abstract methods and call Comment::extend.
<?php class MyStore extends jafaripur\LaravelComments\CommentStore { // ... } Comment::extend('mystore', function($app) { return $app->make('MyStore'); }); ?>
Contact
Open an issue or request pull on GitHub if you have any problems or suggestions.
jafaripur/laravel-comment 适用场景与选型建议
jafaripur/laravel-comment 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 68 次下载、GitHub Stars 达 16, 最近一次更新时间为 2015 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jafaripur/laravel-comment 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jafaripur/laravel-comment 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 68
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache2
- 更新时间: 2015-10-31