<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
thiktak / filament-sql-nested-builder-form example snippets
// use App\Models\User;
use Thiktak\FilamentNestedBuilderForm\Forms\Components\NestedBuilder;
use Thiktak\FilamentNestedBuilderForm\Forms\Components\NestedSubBuilder;
use Thiktak\FilamentSQLNestedBuilderForm\Forms\Components\SQLNestedBuilder;
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('Nested Builder Form')
->description('Example of the SQL Nested Builder Form (SQL Query)')
->schema([
// configuration is an Array
SQLNestedBuilder::make('configuration')
// nestedConfiguration apply this set up to all children
->nestedConfiguration(function (NestedSubBuilder $builder, NestedBuilder $parent) {
// import default configuration of this package
$parent->defaultNestedConfiguration($builder);
})
// Display the first Hint as a Raw SQL query of User Model
->hint(function (?array $state) {
return SQLNestedBuilder::getFullyLinearizedArrayToEloquent($state, User::query())
->getQuery()
->toRawSql()
;
})
]),
]);
}
SQLNestedBuilder::getFullyLinearizedArrayToSQL(?array $state); // If consume the whole array
SQLNestedBuilder::getFullyLinearizedArrayToSQL(?array $state, 'group'); // if level of group
SQLNestedBuilder::getFullyLinearizedArrayToSQL(?array $state, 'rule'); // if level of rule
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.