PHP code example of iamgerwin / nova-dependency-container
1. Go to this page and download the library: Download iamgerwin/nova-dependency-container library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
iamgerwin / nova-dependency-container example snippets
use Iamgerwin\NovaDependencyContainer\NovaDependencyContainer;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
public function fields(NovaRequest $request)
{
return [
Select::make('Type')
->options([
'personal' => 'Personal',
'business' => 'Business',
]),
NovaDependencyContainer::make([
Text::make('Company Name'),
Text::make('Tax ID'),
])->dependsOn('type', 'business'),
NovaDependencyContainer::make([
Text::make('Personal ID'),
Text::make('Date of Birth'),
])->dependsOn('type', 'personal'),
];
}
use Iamgerwin\NovaDependencyContainer\HasDependencies;
use Laravel\Nova\Fields\Text;
class CustomTextField extends Text
{
use HasDependencies;
}
// In your Nova resource:
CustomTextField::make('Special Field')
->dependsOn('type', 'custom')