finagin/laravel-comment 问题修复 & 功能扩展

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

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

finagin/laravel-comment

Composer 安装命令:

composer require finagin/laravel-comment

包简介

Comments for Laravel 5.4 and up

README 文档

README

Latest Version on Packagist Software License Build Status StyleCI Total Downloads

GitHub stars

Installation

This package can be used in Laravel 5.4 or higher. You can install the package via composer:

composer require finagin/laravel-comment

Now add the service provider in config/app.php file:

'providers' => [
    /*
     * Package Service Providers...
     */
    // ...
    Finagin\Comment\CommentServiceProvider::class,
    // ...
];

You must publish the migration with:

php artisan vendor:publish --provider="Finagin\Comment\CommentServiceProvider" --tag="migrations"

After the migration has been published you must create the settings-tables by running the migrations:

php artisan migrate

Also you can publish the config file with:

php artisan vendor:publish --provider="Finagin\Comment\CommentServiceProvider" --tag="config"

Add CanComment trait to your User model.

use Finagin\Comment\Traits\CanComment;

Add Commentable trait to your commentable model(s).

use Finagin\Comment\Traits\Commentable;

If you want to have your own Comment Model create a new one and extend my Comment model.

class Comment extends Finagin\Comment\Models\Comment
{
  ...
}

Comment package comes with several modes.

  1. If you want to Users can rate your model(s) with comment set canBeRated to true in your Commentable model.
class Post extends Model {
  use Commentable;

  protected $canBeRated = true;

  ...
}
  1. If you want to approve comments for your commentable models, you must set mustBeApproved to true in your Commentable model.
class Post extends Model {
  use Commentable;

  protected $mustBeApproved = true;

  ...
}

Usage

$user = App\User::find(1);
$post = App\Post::find(1);

// CanComment->comment(Commentable|Commnet $commentable, string $commentText): Comment

// Anonimous first level comment
$comment = (new User(['name' => 'Anonymous']))->comment($post, 'Lorem ipsum ..');

// Users sub comment
$user
    ->comment($comment, 'Lorem ipsum ..');

// Anonimous sub comment
(new User(['name' => 'Anonymous']))
    ->comment($comment, 'Lorem ipsum ..');

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固