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(); + }); + } +};