From 71bd4b9d1af9c0cefe8615f8055e49a8d9d8eac7 Mon Sep 17 00:00:00 2001 From: brusnitsyn Date: Mon, 22 Jun 2026 16:58:50 +0900 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B0=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/CustomMeasure.php | 32 +++++++++++++++++++ app/Models/ReportDocument.php | 32 +++++++++++++++++++ ...d_parameters_to_report_templates_table.php | 23 +++++++++++++ ...2_100000_create_report_documents_table.php | 29 +++++++++++++++++ ...22_100001_create_custom_measures_table.php | 31 ++++++++++++++++++ ..._22_100002_drop_report_templates_table.php | 27 ++++++++++++++++ 6 files changed, 174 insertions(+) create mode 100644 app/Models/CustomMeasure.php create mode 100644 app/Models/ReportDocument.php create mode 100644 database/migrations/2026_06_22_000000_add_parameters_to_report_templates_table.php create mode 100644 database/migrations/2026_06_22_100000_create_report_documents_table.php create mode 100644 database/migrations/2026_06_22_100001_create_custom_measures_table.php create mode 100644 database/migrations/2026_06_22_100002_drop_report_templates_table.php diff --git a/app/Models/CustomMeasure.php b/app/Models/CustomMeasure.php new file mode 100644 index 0000000..126c674 --- /dev/null +++ b/app/Models/CustomMeasure.php @@ -0,0 +1,32 @@ + 'float', + ]; + + public function creator(): BelongsTo + { + return $this->belongsTo(User::class, 'created_by'); + } +} diff --git a/app/Models/ReportDocument.php b/app/Models/ReportDocument.php new file mode 100644 index 0000000..901cfe1 --- /dev/null +++ b/app/Models/ReportDocument.php @@ -0,0 +1,32 @@ + 'array', + 'period' => 'array', + ]; + + public function creator(): BelongsTo + { + return $this->belongsTo(User::class, 'created_by'); + } +} diff --git a/database/migrations/2026_06_22_000000_add_parameters_to_report_templates_table.php b/database/migrations/2026_06_22_000000_add_parameters_to_report_templates_table.php new file mode 100644 index 0000000..66844ff --- /dev/null +++ b/database/migrations/2026_06_22_000000_add_parameters_to_report_templates_table.php @@ -0,0 +1,23 @@ +json('parameters')->nullable()->after('sections'); + }); + } + + public function down(): void + { + Schema::table('report_templates', function (Blueprint $table) { + $table->dropColumn('parameters'); + }); + } +}; diff --git a/database/migrations/2026_06_22_100000_create_report_documents_table.php b/database/migrations/2026_06_22_100000_create_report_documents_table.php new file mode 100644 index 0000000..c2f8ebe --- /dev/null +++ b/database/migrations/2026_06_22_100000_create_report_documents_table.php @@ -0,0 +1,29 @@ +id(); + $table->string('name'); + $table->string('description')->nullable(); + $table->string('dataset'); + // {dimensions:[], measures:[], filters:[], mode, detalization, chart:{metric,type}} + $table->json('config'); + // дефолтный период отчёта (опц.): {start, end} + $table->json('period')->nullable(); + $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('report_documents'); + } +}; diff --git a/database/migrations/2026_06_22_100001_create_custom_measures_table.php b/database/migrations/2026_06_22_100001_create_custom_measures_table.php new file mode 100644 index 0000000..e87ac04 --- /dev/null +++ b/database/migrations/2026_06_22_100001_create_custom_measures_table.php @@ -0,0 +1,31 @@ +id(); + $table->string('name'); + $table->string('dataset'); + // ключ базового показателя датасета + $table->string('base_measure'); + // sum|avg|count|share — как пересчитать базовый показатель + $table->string('aggregate')->default('sum'); + // множитель (для процента/нормировки), по умолчанию 1 + $table->decimal('factor', 12, 4)->default(1); + $table->string('unit')->nullable(); + $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('custom_measures'); + } +}; diff --git a/database/migrations/2026_06_22_100002_drop_report_templates_table.php b/database/migrations/2026_06_22_100002_drop_report_templates_table.php new file mode 100644 index 0000000..2b62c91 --- /dev/null +++ b/database/migrations/2026_06_22_100002_drop_report_templates_table.php @@ -0,0 +1,27 @@ +id(); + $table->string('name'); + $table->json('sections'); + $table->json('parameters')->nullable(); + $table->json('required_permissions')->nullable(); + $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete(); + $table->timestamps(); + }); + } +};