定制 kirschbaum-development/nova-comments 二次开发

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

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

kirschbaum-development/nova-comments

Composer 安装命令:

composer require kirschbaum-development/nova-comments

包简介

A Laravel Nova resource for commenting on model.

关键字:

README 文档

README

Latest Version on Packagist Total Downloads Codacy Badge

This package contains an inline commenting form for any resource to easily add comments. Think a simple version of Disqus for Nova!

Commenter Tool

screenshot of the commenter resource tool

Simple Comment Panel

screenshot of the comments panel

Requirements

This Nova resource tool requires Nova 4.0 or higher.
For older version of Nova, use the tagged version 1.0.2

Installation

You can install this package in a Laravel app that uses Nova via composer:

composer require kirschbaum-development/nova-comments

Next, we need to run migrations. Auto-discovery of this package's service provider helps with that!

php artisan migrate

And lastly, any model that you want to have comments needs the Commentable trait added to it.

use KirschbaumDevelopment\NovaComments\Commentable;

class Post extends Model
{
    use Commentable;
    
    // ...
}

If you would like to publish the config for this package, run:

php artisan vendor:publish

And choose the provider for this package: KirschbaumDevelopment\NovaComments\NovaCommentsServiceProvider

This package requires that it has a commenter, which is simply a User. Nova Comments automatically defaults to the App\Nova\User resource, but can easily be changed in the publishable config file.

Usage

There are two components that ship with this package, the Commenter and a CommentsPanel.

Commenter

The first, and most useful, component is the Commenter. It is a resource tool that allows you to insert a commenting panel directly onto any Nova resource. This panel allows you to add a comment directly to a resource without needing to create one from the respective create view. The newly created comments show up below the commenting form with live updating.

Simply add the KirschbaumDevelopment\NovaComments\Commenter resource tool in your Nova resource:

namespace App\Nova;

use KirschbaumDevelopment\NovaComments\Commenter;

class Post extends Resource
{
    // ...
    
    public function fields(Request $request)
    {
        return [
            // ...
            
            new Commenter(),

            // ...
        ];
    }
}

Now you can comment from the detail view of any resource you've attached the Commenter to! Happy commenting!

Comments Panel

As a convenience, a prebuilt comments panel has been created for you. All you need to do is simply add it to your resource and enjoy the pre-built goodness.

namespace App\Nova;

use KirschbaumDevelopment\NovaComments\Commenter;

class Post extends Resource
{
    // ...
    
    public function fields(Request $request)
    {
        return [
            // ...
            
            new CommentsPanel(),

            // ...
        ];
    }
}

Of course you are completely free to create your own comments panel, but to get up and running quickly, we recommend using this panel.

Sidebar Navigation

Occasionally you may want to hide comments from the sidebar. You can easily do this by setting the respective config value to false. Make sure to first publish the configs.

'available-for-navigation' => false

Pagination caveat

Due to an limitation in how Nova paginates results, there is currently no way to set the perPage value for the number of comments that will display at a time from a configuration value. Nova's default value is 5 per page. If you would like to set this to a different value, such as 25, we recommend you extend the Commenter and set this value with the follwing code:

use KirschbaumDevelopment\NovaComments\Commenter as NovaCommenter;

class Commenter extends NovaCommenter
{
    /**
     * The number of resources to show per page via relationships.
     *
     * @var int
     */
    public static $perPageViaRelationship = 25;
}

Then use this class instead of the default Commenter class within your resources.

Customizing the comment

By default, the Comment model will strip tags from the comment body. If you would like to modify this behavior, you can pass an callback to the Comment::whenCreating method. This callback will receive the comment model instance as a parameter.

Comment::whenCreating(function (Comment $comment) {
    $comment->comment = strip_tags($comment->comment);
});

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email brandon@kirschbaumdevelopment.com or nathan@kirschbaumdevelopment.com instead of using the issue tracker.

Credits

Sponsorship

Development of this package is sponsored by Kirschbaum Development Group, a developer driven company focused on problem solving, team building, and community. Learn more about us or join us!

License

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

kirschbaum-development/nova-comments 适用场景与选型建议

kirschbaum-development/nova-comments 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 130.46k 次下载、GitHub Stars 达 32, 最近一次更新时间为 2019 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 32
  • Watchers: 15
  • Forks: 37
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-24