|
|
@@ -0,0 +1,49 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+use Illuminate\Database\Migrations\Migration;
|
|
|
+use Illuminate\Database\Schema\Blueprint;
|
|
|
+use Illuminate\Support\Facades\Schema;
|
|
|
+
|
|
|
+return new class extends Migration
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * Run the migrations.
|
|
|
+ */
|
|
|
+ public function up(): void
|
|
|
+ {
|
|
|
+ Schema::table('datatables', function (Blueprint $table) {
|
|
|
+ // Drop 5 old columns
|
|
|
+ $table->dropColumn(['enable_copy', 'enable_csv', 'enable_excel', 'enable_pdf', 'enable_print']);
|
|
|
+
|
|
|
+ // Add new JSON columns for buttons config
|
|
|
+ $buttons = [
|
|
|
+ ['extend' => 'copyHtml5', 'className' => 'dt-button'],
|
|
|
+ ['extend' => 'csvHtml5', 'className' => 'dt-button'],
|
|
|
+ ['extend' => 'excelHtml5', 'className' => 'dt-button'],
|
|
|
+ ['extend' => 'pdfHtml5', 'className' => 'dt-button'],
|
|
|
+ ['extend' => 'print', 'className' => 'dt-button'],
|
|
|
+ ];
|
|
|
+ $table->json('buttons')->default(json_encode($buttons));
|
|
|
+
|
|
|
+ $columnDefs = [
|
|
|
+ ['responsivePriority' => 1, 'targets' => 1],
|
|
|
+ ['responsivePriority' => 2, 'targets' => -1],
|
|
|
+ ['visible' => false, 'targets' => 0]
|
|
|
+ ];
|
|
|
+
|
|
|
+ $table->json('column_defs')->default(json_encode($columnDefs));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Reverse the migrations.
|
|
|
+ */
|
|
|
+ public function down(): void
|
|
|
+ {
|
|
|
+
|
|
|
+ Schema::table('datatables', function (Blueprint $table) {
|
|
|
+ // Drop the new JSON columns
|
|
|
+ $table->dropColumn(['buttons', 'column_defs']);
|
|
|
+ });
|
|
|
+ }
|
|
|
+};
|