vladislavbrum/tb-vl-lara

用于 Laravel Nova 的表格字段

1.4 2023-04-06 16:06 UTC

This package is auto-updated.

Last update: 2024-09-06 18:57:49 UTC


README

Latest Version on Packagist Total Downloads

简单的 Laravel Nova 表格字段。

表单视图

Form View GIF

安装

通过 Composer 在 Laravel Nova 项目中安装此包

composer require optimistdigital/nova-table-field

使用方法

Table 字段提供了一个方便的界面来编辑存储在等价于 JSON 列中的行和列。

use OptimistDigital\NovaTableField\Table;

public function fields(Request $request)
{
    return [
        Table::make('Countries')

        // Optional:
        ->disableAdding() // Disable adding new rows and columns
        ->disableDeleting() // Disable deleting rows and columns
        ->minRows(1) // The minimum number of rows in the table
        ->maxRows(10) // The maximum number of rows in the table
        ->minColumns(1) // The minimum number of columns in the table
        ->maxColumns(10) // The maximum number of columns in the table
    ];
}

请注意,您还需要在模型中将 JSON 数据转换为 数组

protected $casts = ['countries' => 'array'];

本地化

可以使用以下发布命令发布翻译文件

php artisan vendor:publish --provider="OptimistDigital\NovaTableField\FieldServiceProvider" --tag="translations"

然后您可以编辑字符串,使其符合您的喜好。