mrpowerup / filament-sql-field
并提供一个使用 codemirror 5 编写 SQL 语句的字段。
1.1.2
2024-09-05 18:25 UTC
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
安装
您可以通过 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") ->editorHeight(300) // Set height of editor ->dark() // Switch to Dark theme (Dracula Theme) ->autoGetTables() // Automatically get tables from database ->tables(['table1' => ['column1', 'column2', 'column3'], 'table2' => ['column1', 'column2', 'column3']]) // Define tables and columns ->default("SELECT * FROM users WHERE 1;") ->columnSpanFull(), ]); }
定义的 MIME 类型
- 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
如果您需要在此处通过分发更新编辑器值,以下是一个示例
$this->dispatch('updatePlugin', $record->sql);
@script <script> $wire.on('updatePlugin', (event) => { window.editor.setValue(event[0]); }); </script> @endscript
链接
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 获取更多信息。