定制 matthewbdaly/laravel-comments 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱: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).

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固