matthewbdaly/laravel-comments 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

matthewbdaly/laravel-comments

Composer 安装命令:

composer require matthewbdaly/laravel-comments

包简介

Simple Laravel comment system

README 文档

README

Build Status Coverage Status

Simple comments system, loosely inspired by Django's comments system. Allows comments to be attached to an object, and allows for them to be flagged by users for moderator attention.

Installation

composer require matthewbdaly/laravel-comments

You will also need to run php artisan migrate to set up the required database tables.

Usage

To allow comments to be attached to an object, add the trait Matthewbdaly\LaravelComments\Eloquent\Traits\Commentable to it. The object will then have a comments polymorphic relation.

Views

The package includes a view for submitting comments, named comments::comments, which can be included in another view as follows:

@include('comments::comments', ['parent' => $post])

The value of parent must be an instance of the commentable object (eg, a blog post). The view also includes a form for flagging comments.

Obviously, if you prefer you can override this view with your own content.

The package also includes the following views:

  • comments::commentsubmitted
  • comments::flagsubmitted

These simply acknowledge receipt of the comment or flag, but are fairly basic and so you should feel free to replace them as you see fit.

Of course there's nothing stopping you creating your own routes and controllers for creating, viewing and flagging comments, and if you wish to build a REST API that allows for adding comments to objects you can just use these models directly:

  • Matthewbdaly\LaravelComments\Eloquent\Models\Comment
  • Matthewbdaly\LaravelComments\Eloquent\Models\Comment\Flag

I recommend that you use my repositories, which are as follows:

  • Matthewbdaly\LaravelComments\Contracts\Repositories\Comment
  • Matthewbdaly\LaravelComments\Contracts\Repositories\Comment\Flag

These use matthewbdaly/laravel-repositories and so implement caching on the decorated repository, making it simple to ensure your models get cached appropriately.

Events

You can set up listeners for the following events:

  • Matthewbdaly\LaravelComments\Events\CommentBeingReceived

Fired before the comment is saved. The package does not validate comments out of the box, but you can use this to validate the comment using whatever method you wish (eg check it with Akismet, check for links), or process it before saving (eg run it through a Markdown parser).

  • Matthewbdaly\LaravelComments\Events\CommentReceived

Fired when a new comment is submitted. This is useful for creating some sort of notification, such as an SMS, email, push notification etc.

  • Matthewbdaly\LaravelComments\Events\CommentBeingFlagged

Fired before a comment flag is saved. Useful for processing the flag to amend it before saving it.

  • Matthewbdaly\LaravelComments\Events\CommentFlagged

This event fires after a comment has been flagged for moderator attention. You can use this event to send whatever notification is most appropriate (eg, email, Slack, SMS).

matthewbdaly/laravel-comments 适用场景与选型建议

matthewbdaly/laravel-comments 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 563 次下载、GitHub Stars 达 8, 最近一次更新时间为 2017 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「comments」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 matthewbdaly/laravel-comments 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 matthewbdaly/laravel-comments 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 563
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-06