定制 creode/collapsible-radios 二次开发

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

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

creode/collapsible-radios

最新稳定版本:1.1.0

Composer 安装命令:

composer require creode/collapsible-radios

包简介

A single select collapsible radio button module for Laravel Nova.

README 文档

README

Contains a new Laravel Nova field for building collapsible radios for parent and child relationships.

Field in use

Installation

You can install the package via composer:

composer require creode/collapsible-radios

Usage

To create an instance of a new field just use the CollapsibleRadios class in your Nova resource's fields method. You need to ensure that your options provide the following fields:

  • label - The label to display for the option
  • value - The value to use for the option
  • id - The ID of the option
  • parent_id - The ID of the parent option

These fields are used to build the collapsible radios based on parent_ids.

Here is a basic example for how we would accept input for options.

use Creode\CollapseRadios\Field\CollapsibleRadios;

CollapsibleRadios::make('Model', 'model_id')
    ->options([
        [
            'label' => 'Option 1',
            'value' => 1,
            'id' => 1,
            'parent_id' => null,
        ],
        [
            'label' => 'Option 2',
            'value' => 2,
            'id' => 2,
            'parent_id' => 1,
        ],
                [
            'label' => 'Option 3',
            'value' => 3,
            'id' => 3,
            'parent_id' => 2,
        ]
    ])
    ->nullable()
    ->rules('required')

This would generate a structure like the following:

  • Option 1
    • Option 2
      • Option 3

or if you want to easily map model data to it:

use Creode\CollapseRadios\Field\CollapsibleRadios;

CollapsibleRadios::make('Model', 'model_id')
    ->options(
        Model::all()->map(
            function ($model) {
                return [
                    'label' => $model->name,
                    'value' => $model->id,
                    'id' => $model->id,
                    'parent_id' => $model->parent_id ?: null,
                ];
            }
        )
    )
    ->nullable()
    ->rules('required')

Roadmap

We plan to implement the following features as our requirements develop for this project:

  • Allow for a default option to be selected
  • Allow for multiple options to be selected

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固