<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
digital-creative / conditional-container example snippets
use DigitalCreative\ConditionalContainer\ConditionalContainer;
use DigitalCreative\ConditionalContainer\HasConditionalContainer;
class ExampleNovaResource extends Resource {
use HasConditionalContainer; // Important!!
public function fields(Request $request)
{
return [
Select::make('Option', 'option')
->options([
1 => 'Option 1',
2 => 'Option 2',
3 => 'Option 3',
]),
Text::make('Content', 'content')->rules(' 2 && $content > 10) || $option === 3)
*/
ConditionalContainer::make([ Text::make('Field C')->rules(' ])
->if('option = 3 OR content = demo')
];
}
}
ConditionalContainer::make(...)->if('first_name = John');
ConditionalContainer::make(...)->if('(first_name = John AND last_name = Doe) OR (first_name = foo AND NOT last_name = bar)');
ConditionalContainer::make(...)->if('first_name = John AND last_name = Doe');