branchId = $branchId; } public function handle() { $sqlitePath = storage_path('app/database/tempTextAd.sqlite'); if (!file_exists(dirname($sqlitePath))) { mkdir(dirname($sqlitePath), 0755, true); } if (!file_exists($sqlitePath)) { file_put_contents($sqlitePath, ''); } $connectionName = 'tempsqlite_' . md5($sqlitePath . microtime()); config(["database.connections.{$connectionName}" => [ 'driver' => 'sqlite', 'database' => $sqlitePath, 'prefix' => '', ]]); $exporter = new SqliteExportService($connectionName); $exporter->exportMultiple([ 'text_ads' => [ 'query' => fn () => DB::table('text_ads'), 'tableSchema' => function (Blueprint $table) { $table->id(); $table->string('content')->comment('廣告內容'); $table->enum('color', ['black','white', 'red', 'green','blue'])->default('black')->comment('顯示顏色'); $table->integer('duration')->default(1)->comment('播放間隔時間(分鐘)'); $table->boolean('is_active')->default(true); // 啟用狀態 $table->timestamps(); }, 'transformer' => fn ($row) => [ 'content' => $row->content, 'color' => $row->color, 'duration' => $row->duration, 'is_active' => $row->is_active, 'created_at' => $row->created_at, 'updated_at' => $row->updated_at, ], ], ]); SendSqliteFileJob::dispatch($sqlitePath, $this->branchId); } }