瀏覽代碼

Added migration to insert a sample report row into the datatables table.

tyson 8 月之前
父節點
當前提交
544834a10c
共有 1 個文件被更改,包括 70 次插入0 次删除
  1. 70 0
      database/migrations/2025_04_06_144819_insert_sample_report_into_datatables_table.php

+ 70 - 0
database/migrations/2025_04_06_144819_insert_sample_report_into_datatables_table.php

@@ -0,0 +1,70 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Support\Facades\DB;
+
+class InsertSampleReportIntoDatatablesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        DB::table('datatables')->insert([
+            'id' => 1,
+            'name' => 'Employee-Report',
+            'description' => null,
+            'base_table' => 'employees',
+            'select_columns' => json_encode([
+                ['select_exp' => 'employees.name AS employee_name'],
+                ['select_exp' => 'employees.email AS employee_email'],
+                ['select_exp' => 'employees.position AS employee_position'],
+                ['select_exp' => 'offices.name AS office_name'],
+                ['select_exp' => 'offices.location AS office_location']
+            ]),
+            'joins' => json_encode([
+                [
+                    'type' => 'inner',
+                    'table' => 'offices',
+                    'on' => [
+                        'first' => 'employees.office_id',
+                        'operator' => '=',
+                        'second' => 'offices.id'
+                    ]
+                ]
+            ]),
+            'conditions' => null,
+            'default_sorting' => json_encode([
+                ['name' => 'employees.name', 'dir' => 'asc']
+            ]),
+            'created_at' => null,
+            'updated_at' => null,
+            'enable_copy' => 1,
+            'enable_csv' => 1,
+            'enable_excel' => 0,
+            'enable_pdf' => 1,
+            'enable_print' => 1,
+            'columns_config' => json_encode([
+                ['data' => 'employee_name', 'name' => 'employees.name'],
+                ['data' => 'employee_email', 'name' => 'employees.email'],
+                ['data' => 'employee_position', 'name' => 'employees.position'],
+                ['data' => 'office_name', 'name' => 'offices.name'],
+                ['data' => 'office_location', 'name' => 'offices.location']
+            ])
+        ]);
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        DB::table('datatables')->where('id', 1)->delete();
+    }
+}