armincms/chain 问题修复 & 功能扩展

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

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

armincms/chain

最新稳定版本:0.4.2

Composer 安装命令:

composer require armincms/chain

包简介

A Laravel Nova field.

README 文档

README

Conditionally load a field with the value of the other fields.

Installation

Via composer: composer require armincms/chain.

Usage

The Chain field works as a trigger and listener. a trigger chain listens to the update events of entire fields and the listener chain listening to the trigger Chain events and its entire fields together.

Make trigger field

The trigger Chain initializes via the as method. the as method accepts two arguments. the first argument is the name of event and the second argument is a fields callback. it receives a request instance for resolving fields.

        Chain::as('name', function() {
            return [ 
                Text::make('Name')
                    ->sortable()
                    ->rules('required', 'max:255'), 

                Text::make('Username')
                    ->sortable()
                    ->rules('required', 'max:255'), 
            ];  
        }), 

Make listener field

The listener Chain initializes via the with method. the with method accepts an array of events as the first argument and a callback for the fields as second arguemnt. for listening to a trigger Chain you should pass the name of the Chain as the event name. for listening to a field of a trigger Chain you can prefix the field name by the Chain name and listen to it. for example, you can listen to the name field of a Chain (Chain field named by the 'test'), with the test.name event.

        Chain::with('name', function($request) {
            if($request->filled('username')){
                return [ 
                    Text::make('Password')
                        ->sortable()
                        ->rules('required', 'max:255'), 
                        
                    Text::make('Confirmation')
                        ->sortable()
                        ->rules('required', 'max:255'), 
                ];  
            }
            
            return [];
        }, 'second-chain'), 

        
        Chain::with('second-chain.confirmation', function($request) {
            return [ 
                Boolean::make('Passed')
                  ->readonly()
                  ->withMeta(['value' => 1]), 
            ]; 
        }),

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固