定制 alexwenzel/ajax-select 二次开发

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

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

alexwenzel/ajax-select

最新稳定版本:1.1

Composer 安装命令:

composer require alexwenzel/ajax-select

包简介

A Laravel Nova 4 field - Ajax Select

README 文档

README

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

This is a fork of https://github.com/dillingham/nova-ajax-select and only supports nova 4 and php 8.

nova-ajax-select

Install

composer require alexwenzel/ajax-select 

Usage

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

use Alexwenzel\AjaxSelect\AjaxSelect;
BelongsTo::make('Company'), AjaxSelect::make('User') ->get('/api/company/{company}/users') ->parent('company'),

Add the field for index & detail views display. AjaxSelect 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([]), AjaxSelect::make('State') ->get('/api/country/{country}/states') ->parent('country'), AjaxSelect::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'), AjaxSelect::make('File') ->get('/{project}/files') ->parent('project'), AjaxSelect::make('Comment') ->get('/{project}/comments') ->parent('project'),

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 20
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固