承接 jafaripur/laravel-comment 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jafaripur/laravel-comment

Composer 安装命令:

composer require jafaripur/laravel-comment

包简介

Commenting system in laravel

README 文档

README

Persistant, application-wide commenting system for Laravel.

Installation

  1. composer require jafaripur/laravel-comment
  2. Add jafaripur\LaravelComments\ServiceProvider to the array of providers in config/app.php.
  3. 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.
  4. Optional: add 'Comments' => 'jafaripur\LaravelComments\Facade' to the array of aliases in config/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:

  • $query is the query builder instance
  • $insert is 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 jafaripur/laravel-comment 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 68
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Apache2
  • 更新时间: 2015-10-31