A field to write SQL sentences using Codemirror 5.
MIT License
You can install the package via composer:
composer require mrpowerup/filament-sql-field
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(),
]);
}
$this->dispatch('updatePlugin', 'SELECT * FROM table_name WHERE 1;');
@script
<script>
$wire.on('updatePlugin', (event) => {
window.editor.setValue(event[0]);
});
</script>
@endscript
The MIT License (MIT). Please see License File for more information.