定制 parallax/filament-comments 二次开发

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

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

parallax/filament-comments

Composer 安装命令:

composer require parallax/filament-comments

包简介

Add comments to your Filament Resources.

README 文档

README

Latest Version on Packagist Software License Total Downloads Stars

Add comments to your Filament Resources.

Installation

Install the package via composer:

composer require parallax/filament-comments

Publish and run the migrations:

php artisan vendor:publish --tag="filament-comments-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="filament-comments-config"

You can publish the language files with:

php artisan vendor:publish --tag="filament-comments-translations"

Optionally, you can publish the views using

php artisan vendor:publish --tag="filament-comments-views"

Quickstart

1. Add model trait

First open the eloquent model you wish to add Filament Comments to.

namespace App\Models;

use Parallax\FilamentComments\Models\Traits\HasFilamentComments;

class Product extends Model
{
    use HasFilamentComments;
}

2. Add comments to Filament Resource

There are 3 ways of using this plugin in your Filament Resources:

1. Page actions

Open the page where you want the comments action to appear, this will most likely be the ViewResource page.

Add the CommentsAction to the getHeaderActions() method.

<?php

namespace App\Filament\Resources\ProductResource\Pages;

use Parallax\FilamentComments\Actions\CommentsAction;

class ViewProduct extends ViewRecord
{
    protected function getHeaderActions(): array
    {
        return [
            CommentsAction::make(),
        ];
    }
}

You may customise the page action as you would any other action.

2. Table actions

Open the resource where you want the comments table action to appear.

Add the CommentsAction to the $table->actions() method.

<?php

namespace App\Filament\Resources;

use Parallax\FilamentComments\Tables\Actions\CommentsAction;

class ProductResource extends Resource
{
    public static function table(Table $table): Table
    {
        return $table
            ->actions([
                CommentsAction::make(),
            ]);
    }
}

You may customise the table action as you would any other action.

3. Infolist entry

It's also possible to use the comments component within your infolist.

Add the CommentsEntry to the $infolist->schema() method.

<?php

namespace App\Filament\Resources;

use Parallax\FilamentComments\Infolists\Components\CommentsEntry;

class ProductResource extends Resource
{
    public static function infolist(Infolist $infolist): Infolist
    {
        return $infolist
            ->schema([
                CommentsEntry::make('filament_comments'),
            ]);
    }
}

Please note that this cannot be used in combination with a comments action on the same page.

Authorisation

By default, all users can view & create comments as well as only delete their own comments.

If you would like to change this behaviour you can create your own eloquent model policy for the Parallax\FilamentComments\Models\FilamentComment model.

You should define the policy class in the filament-comments config file.

return [
    'model_policy' => \Parallax\FilamentComments\Policies\FilamentCommentPolicy::class,
];

Pruning deleted comments

Comment records are set to be pruned after 30 days of being soft-deleted by default. You may change this value in the config file:

return [
    'prune_after_days' => 30,
];

After configuring the model, you should schedule the model:prune Artisan command in your application's Kernel class. Don't forget to explicitly mention the FilamentComment class. You are free to choose the appropriate interval at which this command should be run:

namespace App\Console;

use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Parallax\FilamentComments\Models\FilamentComment;

class Kernel extends ConsoleKernel
{
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('model:prune', [
            '--model' => [FilamentComment::class],
        ])->daily();
    
        // This will not work, as models in a package are not used by default
        // $schedule->command('model:prune')->daily();
    }
}

Changelog

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

Credits

License

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

parallax/filament-comments 适用场景与选型建议

parallax/filament-comments 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 256.98k 次下载、GitHub Stars 达 134, 最近一次更新时间为 2024 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 256.98k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 134
  • 点击次数: 22
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 134
  • Watchers: 6
  • Forks: 72
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-30