New report system and views

This commit is contained in:
Simon Pocrnjič
2026-01-02 12:32:20 +01:00
parent 9fc5b54b8a
commit 703b52ff59
67 changed files with 8255 additions and 2794 deletions
@@ -0,0 +1,36 @@
<?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::create('reports', function (Blueprint $table) {
$table->id();
$table->string('slug')->unique();
$table->string('name');
$table->text('description')->nullable();
$table->string('category', 100)->nullable();
$table->boolean('enabled')->default(true);
$table->integer('order')->default(0);
$table->timestamps();
$table->index('slug');
$table->index(['enabled', 'order']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('reports');
}
};
@@ -0,0 +1,38 @@
<?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::create('report_columns', function (Blueprint $table) {
$table->id();
$table->foreignId('report_id')->constrained()->cascadeOnDelete();
$table->string('key', 100);
$table->string('label');
$table->string('type', 50)->default('string');
$table->text('expression');
$table->boolean('sortable')->default(true);
$table->boolean('visible')->default(true);
$table->integer('order')->default(0);
$table->json('format_options')->nullable();
$table->timestamps();
$table->index(['report_id', 'order']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('report_columns');
}
};
@@ -0,0 +1,37 @@
<?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::create('report_entities', function (Blueprint $table) {
$table->id();
$table->foreignId('report_id')->constrained()->cascadeOnDelete();
$table->string('model_class');
$table->string('alias', 50)->nullable();
$table->enum('join_type', ['base', 'join', 'leftJoin', 'rightJoin'])->default('base');
$table->string('join_first', 100)->nullable();
$table->string('join_operator', 10)->nullable();
$table->string('join_second', 100)->nullable();
$table->integer('order')->default(0);
$table->timestamps();
$table->index(['report_id', 'order']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('report_entities');
}
};
@@ -0,0 +1,38 @@
<?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::create('report_filters', function (Blueprint $table) {
$table->id();
$table->foreignId('report_id')->constrained()->cascadeOnDelete();
$table->string('key', 100);
$table->string('label');
$table->string('type', 50);
$table->boolean('nullable')->default(true);
$table->text('default_value')->nullable();
$table->json('options')->nullable();
$table->string('data_source')->nullable();
$table->integer('order')->default(0);
$table->timestamps();
$table->index(['report_id', 'order']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('report_filters');
}
};
@@ -0,0 +1,39 @@
<?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::create('report_conditions', function (Blueprint $table) {
$table->id();
$table->foreignId('report_id')->constrained()->cascadeOnDelete();
$table->string('column');
$table->string('operator', 50);
$table->string('value_type', 50);
$table->text('value')->nullable();
$table->string('filter_key', 100)->nullable();
$table->enum('logical_operator', ['AND', 'OR'])->default('AND');
$table->integer('group_id')->nullable();
$table->integer('order')->default(0);
$table->boolean('enabled')->default(true);
$table->timestamps();
$table->index(['report_id', 'group_id', 'order']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('report_conditions');
}
};
@@ -0,0 +1,33 @@
<?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::create('report_orders', function (Blueprint $table) {
$table->id();
$table->foreignId('report_id')->constrained()->cascadeOnDelete();
$table->string('column');
$table->enum('direction', ['ASC', 'DESC'])->default('ASC');
$table->integer('order')->default(0);
$table->timestamps();
$table->index(['report_id', 'order']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('report_orders');
}
};