mrpowerup / filament-sql-field
And a field to write SQL sentences using codemirror 5.
Installs: 538
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Language:JavaScript
Requires
- php: ^8.1
- filament/forms: ^3.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
README
Installation
You can install the package via composer:
composer require mrpowerup/filament-sql-field
Usage
use MrPowerUp\FilamentSqlField\FilamentSqlField;
public static function form(Form $form): Form { return $form ->schema([ FilamentSqlField::make('sql') ->mime('text/x-mysql') // Define MIME Type ->fullscreen() // Allow Fullscreen mode // ->hintIcon('heroicon-m-question-mark-circle', tooltip: "F11: Fullscreen | Ctrl + Space: Autocomplete | ESC: Exit Fullscreen mode") ->connection('mysql') // Set connection ->autoGetTables() // Automatically get tables from database ->editorHeight(300) // Set height of editor ->dark() // Switch to Dark theme (Dracula Theme) ->default("SELECT * FROM users WHERE 1;") // Default SQL ->tables([ 'table1' => [ 'column1', 'column2', 'column3' ], 'table2' => [ 'column1', 'column2', 'column3' ] ]) // Manually set tables ->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', 'SELECT * FROM table_name WHERE 1;');
Optional (Already included in the view)
@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.