valentin-morice/filament-json-column 问题修复 & 功能扩展

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

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

valentin-morice/filament-json-column

最新稳定版本:v3.0.0

Composer 安装命令:

composer require valentin-morice/filament-json-column

包简介

A simple package to view and edit your JSON columns in Filament

README 文档

README

v3.0 - Filament 4 Support

Now supports Filament 4.x with the new unified schema system!

Version Compatibility

  • v3.x: Filament 4.x, Laravel 11.x, PHP 8.2+
  • v2.x: Filament 3.x, Laravel 10.x+, PHP 8.1+ (maintenance branch)

A simple package to view and edit your JSON columns in Filament 4.

image image

Installation

You can install the package via composer:

composer require valentin-morice/filament-json-column

For Filament 3.x support, use version 2.x:

composer require valentin-morice/filament-json-column:^2.0

Usage

The filament-json-column plugin works as any other Filament Form Builder classes. Make sure the column on which it is called is cast to JSON or array within your Eloquent model.

use ValentinMorice\FilamentJsonColumn\JsonColumn;
use ValentinMorice\FilamentJsonColumn\JsonInfolist;
use Filament\Schemas\Schema;

public static function form(Schema $schema): Schema
    {
        return $schema
            ->schema([
                JsonColumn::make('example'),
            ]);
    }

// An infolist component is also available.
public static function infolist(Schema $schema): Schema
    {
        return $schema
            ->schema([
                JsonInfolist::make('example'),
            ]);
    }

The form component provides you with two tabs: Viewer & Editor. The Viewer tab pretty prints your JSON data, while the Editor tab lets you edit it conveniently. All the methods provided by the plugin accept closures, injected with standard Filament utilities.

Personalize the accent color

The tab selector menu uses the slateblue CSS color by default. However, you can choose any other color:

JsonColumn::make('example')->accent(string '#FFFFFF'|Closure); // The input needs to be a valid CSS color

Display a single tab

If you'd like to use only one of the tabs, without giving your user the possibility to switch to another, use the following methods:

JsonColumn::make('example')->editorOnly(bool|Closure); // Displays only the editor tab
JsonColumn::make('example')->viewerOnly(bool|Closure); // Displays only the viewer tab

Change the height

JsonColumn::make('example')->editorHeight(int 500|Closure); // Accepts an int, defaults to 300
JsonColumn::make('example')->viewerHeight(int 500|Closure); // Accepts an int, defaults to 300

Editor modes

Customize the editor modes. Accepted values (and default) are: ['code', 'form', 'text', 'tree', 'view', 'preview']

JsonColumn::make('example')->modes(array|Closure ['code', 'text', 'tree']);

Validation

Values are validated as proper JSON by default.

Compatibility

  • Filament 4.x (v3.x of this package)
  • Filament 3.x (v2.x of this package - see 2.x branch)
  • Laravel 11.x
  • PHP 8.2+

Credits

I've taken inspiration from the following plugins: Pretty JSON & JSONeditor.

License

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

统计信息

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

GitHub 信息

  • Stars: 57
  • Watchers: 3
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-08