Package Data | |
---|---|
Maintainer Username: | orlyapps |
Package Create Date: | 2018-08-31 |
Package Last Update: | 2023-08-21 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:03:54 |
Package Statistics | |
---|---|
Total Downloads: | 713,512 |
Monthly Downloads: | 8,413 |
Daily Downloads: | 500 |
Total Stars: | 181 |
Total Watchers: | 3 |
Total Forks: | 65 |
Total Open Issues: | 43 |
This version is compatible with Laravel 5.8 and newer.
If you use an older version of Laravel you can use an older version of the package. These aren't maintained anymore, but they should be pretty stable. We still accept small bugfixes.
You can install the package in to a Laravel app that uses Nova via composer:
composer require orlyapps/nova-belongsto-depend
Use this field in your Nova Resource
use Orlyapps\NovaBelongsToDepend\NovaBelongsToDepend;
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']);
})
->fallback(
Text::make('Location Name')->rules('required', 'max:255'),
)
->hideLinkToResourceFromDetail()
->hideLinkToResourceFromIndex()
->nullable()
->dependsOn('Company'),
];
}
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'),
];
}
If you discover any security related issues, please email info@orlyapps.de instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.