update api and add more features

This commit is contained in:
root
2026-06-04 02:24:41 -04:00
parent fa6c9519a0
commit 4e33882ac7
131 changed files with 34596 additions and 340 deletions
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (Schema::hasTable('level_progressions')) {
return;
}
Schema::create('level_progressions', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('current_level_id')->nullable()->index();
$table->string('current_level_name', 100);
$table->unsignedInteger('next_level_id')->nullable()->index();
$table->string('next_level_name', 100)->nullable();
$table->unsignedSmallInteger('order_index')->default(0);
$table->boolean('is_terminal')->default(false);
$table->boolean('is_active')->default(true);
$table->text('notes')->nullable();
$table->timestamps();
$table->unique('current_level_name', 'uq_level_progressions_current_level_name');
});
}
public function down(): void
{
Schema::dropIfExists('level_progressions');
}
};
@@ -0,0 +1,64 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (Schema::hasTable('student_promotion_records')) {
return;
}
Schema::create('student_promotion_records', function (Blueprint $table) {
$table->id('promotion_id');
$table->unsignedInteger('student_id')->index();
$table->unsignedInteger('parent_id')->nullable()->index();
$table->string('current_school_year', 9);
$table->string('next_school_year', 9);
$table->unsignedInteger('current_level_id')->nullable();
$table->unsignedInteger('promoted_level_id')->nullable();
$table->string('current_level_name', 100)->nullable();
$table->string('promoted_level_name', 100)->nullable();
// Promotion lifecycle status (matches plan section 3)
$table->string('promotion_status', 40)->default('not_reviewed');
$table->boolean('passed_current_level')->nullable();
$table->decimal('final_average', 6, 2)->nullable();
$table->boolean('attendance_ok')->nullable();
$table->text('eligibility_notes')->nullable();
$table->boolean('enrollment_required')->default(true);
$table->string('enrollment_status', 40)->default('not_started');
$table->unsignedBigInteger('enrollment_id')->nullable()->index();
$table->dateTime('parent_notified_at')->nullable();
$table->date('enrollment_deadline')->nullable();
$table->dateTime('enrollment_started_at')->nullable();
$table->dateTime('enrollment_completed_at')->nullable();
$table->dateTime('promotion_finalized_at')->nullable();
$table->boolean('info_confirmed')->default(false);
$table->boolean('documents_uploaded')->default(false);
$table->boolean('agreement_accepted')->default(false);
$table->boolean('payment_completed')->default(false);
$table->unsignedInteger('updated_by')->nullable();
$table->timestamps();
$table->unique(['student_id', 'next_school_year'], 'uq_promotion_student_year');
$table->index('promotion_status', 'idx_promotion_status');
$table->index(['next_school_year', 'promotion_status'], 'idx_promotion_year_status');
});
}
public function down(): void
{
Schema::dropIfExists('student_promotion_records');
}
};
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (Schema::hasTable('promotion_audit_log')) {
return;
}
Schema::create('promotion_audit_log', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('promotion_id')->nullable()->index();
$table->unsignedInteger('student_id')->nullable()->index();
$table->unsignedInteger('user_id')->nullable()->comment('Actor that performed the action');
$table->string('action_type', 60);
$table->string('field', 60)->nullable();
$table->string('old_value', 191)->nullable();
$table->string('new_value', 191)->nullable();
$table->text('notes')->nullable();
$table->timestamp('performed_at')->useCurrent();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('promotion_audit_log');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (Schema::hasTable('promotion_reminders_log')) {
return;
}
Schema::create('promotion_reminders_log', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('promotion_id')->index();
$table->unsignedInteger('student_id')->nullable()->index();
$table->unsignedInteger('parent_id')->nullable();
$table->string('reminder_type', 40)->default('manual')
->comment('first|halfway|final|expiration|manual');
$table->string('channel', 20)->default('in_app');
$table->string('subject', 191)->nullable();
$table->text('message')->nullable();
$table->dateTime('sent_at')->nullable();
$table->unsignedInteger('sent_by')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('promotion_reminders_log');
}
};