承接 gabrielesbaiz/nova-ajax-select 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

gabrielesbaiz/nova-ajax-select

最新稳定版本:1.0.0

Composer 安装命令:

composer require gabrielesbaiz/nova-ajax-select

包简介

Ajax select / child select package for Laravel Nova.

README 文档

README

Latest Version on Packagist Total Downloads

Ajax select / child select package for Laravel Nova.

Original code from alexwenzel/nova-ajax-select

Features

  • ✅ Ajax populated select fields based on the values of other fields and when they change

Installation

You can install the package via composer:

composer require gabrielesbaiz/nova-ajax-select

Usage

$novaAjaxSelect = new Gabrielesbaiz\NovaAjaxSelect();
echo $novaAjaxSelect->echoPhrase('Hello, Gabrielesbaiz!');

Specify a request url & optionally the parent($attribute) to watch & trigger the ajax select:

use Gabrielesbaiz\NovaAjaxSelect\NovaAjaxSelect;;
BelongsTo::make('Company'),

NovaAjaxSelect::make('User')
    ->get('/api/company/{company}/users')
    ->parent('company'),

Add the field for index & detail views display. NovaAjaxSelect is for forms only

BelongsTo::make('User')->exceptOnForms(),

Request Url:

In the above example, we say company is the parent.

The {company} url parameter will equal the selected Company field value.

Response Format:

The select field expects a value & display. Map your results like so:

Route::get('api/company/{company}/users', function($company_id) {

    $company = \App\Company::find($company_id);

    return $company->users->map(function($user) {
        return [ 'value' => $user->id, 'display' => $user->name ];
    });
})->middleware(['nova']);

Make children depend on other children

City makes a request based on State, which makes a request based on Country:

Select::make('Country')
    ->options([]),

NovaAjaxSelect::make('State')
    ->get('/api/country/{country}/states')
    ->parent('country'),

NovaAjaxSelect::make('City')
    ->get('/api/state/{state}/cities')
    ->parent('state'),

Make multiple children depend on one parent

File & Comment will both make a request based on Project

BelongsTo::make('Project'),

NovaAjaxSelect::make('File')
    ->get('/{project}/files')
    ->parent('project'),

NovaAjaxSelect::make('Comment')
    ->get('/{project}/comments')
    ->parent('project'),

Testing

composer test

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.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-03