Skip to content

Interactive field that allows you to type, validate, and format SQL statements with syntax checking. It also allows for intuitive construction of SELECT queries and export of results in CSV, Excel, and JSON formats.

License

Notifications You must be signed in to change notification settings

MrPowerUp82/filament-sql-field

Repository files navigation

filament-sql-field

image image image

Installation Filament v4.x

You can install the package via composer:

composer require mrpowerup/filament-sql-field "dev-filament-v4"

Installation Filament v3.x

You can install the package via composer:

composer require mrpowerup/filament-sql-field

Or if you want to use 1.x version of the package you can use:

composer require mrpowerup/filament-sql-field "^1.0"

Or if you want to use 2.x version of the package you can use:

composer require mrpowerup/filament-sql-field "^2.0"

Usage

use MrPowerUp\FilamentSqlField\FilamentSqlSection;
use MrPowerUp\FilamentSqlField\FilamentSqlField;
public static function form(Form $form): Form
    {
        return $form
            ->schema([
                   FilamentSqlSection::make()
                    ->schema([
                        FilamentSqlField::make('sql')                               
                            ->fullscreen() // Allow Fullscreen mode
                            ->editorHeight(300) // Set height of editor
                            ->autoGetTables() // Automatically get tables from database
                            ->default("SELECT * FROM users WHERE 1;")
                            ->columnSpanFull(),
                    ])
            ]);
    }

MIME types defined

  • text/x-sql
  • text/x-mysql
  • text/x-mariadb
  • text/x-cassandra
  • text/x-plsql
  • text/x-mssql
  • text/x-hive
  • text/x-pgsql
  • text/x-gql
  • text/x-gpsql
  • text/x-esper
  • text/x-sqlite
  • text/x-sparksql
  • text/x-trino

If you need to update the editor value with dispatch here is an example:

$this->dispatch('updatePlugin', $record->sql);
@script
    <script>
        $wire.on('updatePlugin', (event) => {
            window.editor.setValue(event[0]);
        });
    </script>
@endscript

Links

License

The MIT License (MIT). Please see License File for more information.

About

Interactive field that allows you to type, validate, and format SQL statements with syntax checking. It also allows for intuitive construction of SELECT queries and export of results in CSV, Excel, and JSON formats.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published