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'),
    ];
}

NovaDependencyContainer::make([
    Text::make('Company Name'),
])->dependsOn('type', 'business')

NovaDependencyContainer::make([
    Text::make('Priority Note'),
])->dependsOnIn('status', ['urgent', 'high'])

NovaDependencyContainer::make([
    Text::make('Cancellation Reason'),
])->dependsOnNot('status', 'active')

NovaDependencyContainer::make([
    Text::make('Additional Info'),
])->dependsOnNotIn('status', ['completed', 'cancelled'])

NovaDependencyContainer::make([
    Text::make('Default Value'),
])->dependsOnEmpty('custom_value')

NovaDependencyContainer::make([
    Textarea::make('Description'),
])->dependsOnNotEmpty('title')

NovaDependencyContainer::make([
    Text::make('Free tier features'),
])->dependsOnNullOrZero('subscription_plan')

NovaDependencyContainer::make([
    Text::make('Premium Features'),
    Text::make('Custom Domain'),
])->dependsOn('plan', 'premium')
  ->dependsOnNotEmpty('company_name')
  ->dependsOnNot('status', 'suspended')

NovaDependencyContainer::make(function () {
    return [
        Text::make('Dynamic Field 1'),
        Text::make('Dynamic Field 2'),
    ];
})->dependsOn('type', 'dynamic')

NovaDependencyContainer::make([
    Text::make('Field 1'),
    Text::make('Field 2'),
])->dependsOn('type', 'special')
  ->applyToFields()

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')

use Iamgerwin\NovaDependencyContainer\NovaDependencyContainer;
use Whitecube\NovaFlexibleContent\Flexible;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;

Flexible::make('Overlay Items')
    ->addLayout('Overlay Item', 'overlay_item', [
        Select::make('Type')
            ->options([
                'Default' => 'Default',
                'Location' => 'Location',
                'Contact Us' => 'Contact Us',
            ]),

        NovaDependencyContainer::make([
            Text::make('Recipient Email', 'recipient_email')
                ->rules('nullable', 'email', 'max:255'),
        ])->dependsOn('type', 'Contact Us'),

        NovaDependencyContainer::make([
            Text::make('Location Name', 'location_name'),
            Text::make('Address', 'address'),
        ])->dependsOn('type', 'Location'),
    ]),

public function fields(NovaRequest $request)
{
    return [
        Select::make('Step')
            ->options([
                '1' => 'Basic Info',
                '2' => 'Address',
                '3' => 'Confirmation',
            ]),

        NovaDependencyContainer::make([
            Text::make('First Name')->        ])->dependsOn('step', '2'),

        NovaDependencyContainer::make([
            Boolean::make('Confirm Details'),
            Textarea::make('Additional Notes'),
        ])->dependsOn('step', '3'),
    ];
}

public function fields(NovaRequest $request)
{
    return [
        Select::make('Payment Method')
            ->options([
                'credit_card' => 'Credit Card',
                'bank_transfer' => 'Bank Transfer',
                'paypal' => 'PayPal',
            ]),

        NovaDependencyContainer::make([
            Text::make('Card Number')
                ->          ->
bash
composer analyse