alvinhu/nova-child-select
最新稳定版本:1.0.5
Composer 安装命令:
composer require alvinhu/nova-child-select
包简介
Laravel nova child field.
README 文档
README
This field allows you to dynamically fill options of the select based on value in parent select field.
Field is based on nova-ajax-select. But instead of providing api endpoint, you can fill options by a closure function.
Install
composer require alvinhu/nova-child-select
Usage
Class have 2 special methods on top of default Select from Laravel Nova.
parent should be a select field or another child select this one depends on.
options should be a callable. it will receive parent select field's value as first argument and should return an array to be shown on the child select field.
Example
use Alvinhu\ChildSelect\ChildSelect;
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Select::make('Country')
->options(Country::all()->mapWithKeys(function ($country) {
return [$country->id => $country->name];
}))
->rules('required'),
ChildSelect::make('City')
->parent('country')
->options(function ($value) {
City::whereCountry($value)->get()->mapWithKeys(function ($city) {
return [$city->id => $city->name];
});
})
->rules('required'),
];
}
统计信息
- 总下载量: 170.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 1
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-17
