carloscgo/nova-belongsto-depend
Composer 安装命令:
composer require carloscgo/nova-belongsto-depend
包简介
A Laravel Nova field.
README 文档
README
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require carloscgo/nova-belongsto-depend
Use this field in your Nova Resource
public function fields(Request $request) { return [ ID::make()->sortable(), Text::make('Name')->rules('required', 'max:255'), NovaBelongsToDepend::make('Company') ->options(\App\Company::all()), NovaBelongsToDepend::make('Department') ->optionsResolve(function ($company) { // Reduce the amount of unnecessary data sent return $company->departments()->get(['id','name']); }) ->dependsOn('Company'), NovaBelongsToDepend::make('Location') ->optionsResolve(function ($company) { // Reduce the amount of unnecessary data sent return $company->locations()->get(['id','name']); }) ->dependsOn('Company'), ]; }
Sample
- Warehouse hasMany Articles
- Articles belongsToMany Suppliers
- Suppliers belongsToMany Articles
- Select a Warehouse and get all articles of the warehouse
- Select a Article and get all suppliers who has this article
public function fields(Request $request) { return [ ID::make()->sortable(), Text::make('Name')->rules('required', 'max:255'), NovaBelongsToDepend::make('Warehouse') ->options(\App\Warehouse::all()) ->rules('required'), NovaBelongsToDepend::make('Article') ->optionsResolve(function ($warehouse) { return $warehouse->articles; }) ->dependsOn('Warehouse') ->rules('required'), NovaBelongsToDepend::make('Supplier') ->optionsResolve(function ($article) { return \App\Supplier::whereHas('articles', function ($q) use ($article) { $q->where('article_id', $article->id); })->get(); }) ->dependsOn('Article') ->rules('required'), ]; }
Security
If you discover any security related issues, please email info@orlyapps.de instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-11-30
