定制 blendbyte/nova-items-field 二次开发

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

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

blendbyte/nova-items-field

最新稳定版本:2.0.1

Composer 安装命令:

composer require blendbyte/nova-items-field

包简介

Nova field to handle array columns

README 文档

README

Laravel Nova array items field with sorting, validation & many display options

nova-array-input-field

Installation

composer require blendbyte/nova-items-field

Usage

use NovaItemsField\Items;
function fields() {
    return [
        Items::make('Emails')
    ]
}

and be sure to cast the property as an array on your eloquent model

public $casts = [
    'emails' => 'array'
];

Validation

Use Laravel's built in array validation

Items::make('Emails')->rules([
     null => 'required|min:2'
     '*' => 'email|min:10',
]),

In this case, an error is produced if there aren't at least 2 items in the array and if each item is not a valid email or is shorter than 10 characters.

You might prefer to use explicit attribute names, the behaviour is exactly the same as before

Items::make('Emails', 'user_email')->rules([
    'user_email' => 'required|min:2',
    'user_email.*' => 'email|min:10',
]),

Array processing

Use the array to perform other actions by making an observer

function saving($user)
{
    foreach($user->emails as $email)
    {
        //
    }
}

Replace item vue component

Here's a brief walkthrough to customize the vue item - view

Additional options

function description default
->max(number) limit number of items allowed false
->draggable() turn on drag/drop sorting false
->fullWidth() increase the width of field area false
->maxHeight(pixel) limit the height of the list false
->listFirst() move add new to the bottom false
->inputType(text) text, date, etc "text"
->placeholder($value) the new item input text "Add a new item"
->deleteButtonValue($value) value for delete button "x"
->createButtonValue($value) value for create button "Add"
->hideCreateButton() hide the "add" button false
->indexAsList() display items as list on index instead of total number false
->detailsAsTotal() display total of items on detail view instead of list false

统计信息

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

GitHub 信息

  • Stars: 14
  • Watchers: 2
  • Forks: 37
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-12