PHPackages                             thiktak/filament-sql-nested-builder-form - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. thiktak/filament-sql-nested-builder-form

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

thiktak/filament-sql-nested-builder-form
========================================

Plugin for FilamentPHP - SQL Nested Builder Form Component

3.x-dev(2y ago)05[1 PRs](https://github.com/Thiktak/filament-sql-nested-builder-form/pulls)MITPHPPHP ^8.1

Since Sep 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Thiktak/filament-sql-nested-builder-form)[ Packagist](https://packagist.org/packages/thiktak/filament-sql-nested-builder-form)[ Docs](https://github.com/Thiktak/filament-sql-nested-builder-form)[ GitHub Sponsors](https://github.com/Thiktak)[ RSS](/packages/thiktak-filament-sql-nested-builder-form/feed)WikiDiscussions 3.x Synced 1mo ago

READMEChangelog (1)Dependencies (15)Versions (3)Used By (0)

filament-sql-nested-builder-form
================================

[](#filament-sql-nested-builder-form)

[![Latest Version on Packagist](https://camo.githubusercontent.com/49d11b38dbbc048077b2e6a7362ecee21b6ee006277869af948239dca48a7727/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7468696b74616b2f66696c616d656e742d73716c2d6e65737465642d6275696c6465722d666f726d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thiktak/filament-sql-nested-builder-form)[![GitHub Tests Action Status](https://camo.githubusercontent.com/679e4f48e793b65c62da68e05fd1cffe11c528abc287addaf00c4dd6fa5d2840/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7468696b74616b2f66696c616d656e742d73716c2d6e65737465642d6275696c6465722d666f726d2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/thiktak/filament-sql-nested-builder-form/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/2b58cbae5d8da361ae176db712308334ff27d89f16da6121e644eec838a4739a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7468696b74616b2f66696c616d656e742d73716c2d6e65737465642d6275696c6465722d666f726d2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/thiktak/filament-sql-nested-builder-form/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/21484f25ce426d544d30d29b9776cd9f62b7dd86dc63ed485707f79057fe8632/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7468696b74616b2f66696c616d656e742d73716c2d6e65737465642d6275696c6465722d666f726d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thiktak/filament-sql-nested-builder-form)

An application of [thiktak/filament-nested-builder-form](https://github.com/Thiktak//filament-nested-builder-form) for SQL with (not) AND/OR and sub-groups.

Warning

Be careful, this package is not yet recommended for production. Help us with testing and feedback :)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require thiktak/filament-sql-nested-builder-form
```

This package is based on [thiktak/filament-nested-builder-form](https://github.com/Thiktak//filament-nested-builder-form).

Usage
-----

[](#usage)

```
// 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()
                                ;
                            })
                    ]),
            ]);
    }
```

Configuration
-------------

[](#configuration)

### Change the field Input (name of the field)

[](#change-the-field-input-name-of-the-field)

Use the nestedConfiguration and set up `fieldComponent`

```
    SQLNestedBuilder::make('configuration')

        ->nestedConfiguration(function (NestedSubBuilder $builder, NestedBuilder $parent) {
            // import default configuration of this package
            $parent->defaultNestedConfiguration($builder);

            // Change the TextInput -> Select
            $parent->fieldComponent(
                fn () => Select::make('field')
                    ->options([
                        'id'    => 'User Id',
                        'email' => 'User email',
                    ])
                    ->searchable()
            );
        })
```

### Export to SQL (string)

[](#export-to-sql-string)

This method will return the Raw SQL of a User model query. $state is the data array.

```
SQLNestedBuilder::getFullyLinearizedArrayToEloquent($state, User::query())
    ->getQuery()
    ->toRawSql()
```

Output (example):

```
select *
  from `users`
  where (
    (
      not (
        (`a` = '1') and (`b` in ('2', '3'))
        and (`a` between '1' and '99')
      )
      or (`email` LIKE '%admin.com%')
      or (`email` LIKE 'a%')
      or (`email` LIKE '%com')
    )
    and (`tenant_id` = '1')
  )
```

### Export to Eloquent

[](#export-to-eloquent)

```
  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
```

Output (example):

```
(`a` = '1' AND `b` IN ('2', '3') AND `a` BETWEEN '1' AND '99') AND `email` LIKE '%admin.com%' AND `email` LIKE 'a%' AND `email` LIKE '%com'
```

### Add custom operators

[](#add-custom-operators)

(current solution) Extend the SQLNesterBuilder, and redefine the method loadDefinition() with a call to `$this->registerOperator(MyOperator::class)`

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Thiktak](https://github.com/Thiktak)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

970d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ef3483ac3589f636895ca82ee45a39a84c1561ebe648f6b500cdfe3b58a1b54?d=identicon)[Thiktak](/maintainers/Thiktak)

---

Top Contributors

[![Thiktak](https://avatars.githubusercontent.com/u/1201486?v=4)](https://github.com/Thiktak "Thiktak (12 commits)")

---

Tags

laravelfilament-pluginThiktakfilament-nested-builder-formfilament-sql-nested-builder-form

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/thiktak-filament-sql-nested-builder-form/health.svg)

```
[![Health](https://phpackages.com/badges/thiktak-filament-sql-nested-builder-form/health.svg)](https://phpackages.com/packages/thiktak-filament-sql-nested-builder-form)
```

###  Alternatives

[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

320392.1k17](/packages/codewithdennis-filament-select-tree)[thiktak/filament-nested-builder-form

Plugin for FilamentPHP - Nested Builder Form Component

208.6k1](/packages/thiktak-filament-nested-builder-form)[ralphjsmit/laravel-filament-components

A collection of reusable components for Filament.

10972.2k2](/packages/ralphjsmit-laravel-filament-components)[jaocero/radio-deck

Turn filament default radio button into a selectable card with icons, title and description.

83281.2k5](/packages/jaocero-radio-deck)[schmeits/filament-character-counter

This is a Filament character counter TextField and Textarea form field for Filament v4 and v5

33184.7k6](/packages/schmeits-filament-character-counter)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
