mrpowerup/filament-sql-field

并提供一个使用 codemirror 5 编写 SQL 语句的字段。

安装: 179

依赖项: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 0

开放问题: 0

语言:JavaScript

1.1.2 2024-09-05 18:25 UTC

This package is auto-updated.

Last update: 2024-09-06 12:05:28 UTC


README

image image

安装

您可以通过 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)。请参阅 许可证文件 获取更多信息。