- Laravel 13.9 + PHP 8.5 + MySQL - Bootstrap 5.3 + jQuery 3.7 + Chart.js (replacing Alpine/Tailwind) - Packages: intervention/image, dompdf, simple-qrcode, league/csv, laravel/breeze, laravel/boost - 17 database migrations: users, programs, qr_codes, participants, attendances, certificates, questionnaires, email_logs, audit_logs - 13 Eloquent models with full relationships - Admin layout (Bootstrap 5 sidebar) + public layout (mobile-first) - Rate limiters: checkin (60/min), certificate (30/min) - Admin seeder: admin@mbip.gov.my - Storage directories + symlink configured Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
41 lines
1.6 KiB
PHP
41 lines
1.6 KiB
PHP
<?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
|
|
{
|
|
Schema::create('certificates', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->uuid('uuid')->unique();
|
|
$table->foreignId('program_id')->constrained('programs')->cascadeOnDelete();
|
|
$table->foreignId('participant_id')->constrained('participants')->cascadeOnDelete();
|
|
$table->foreignId('certificate_template_id')->nullable()->constrained('certificate_templates')->nullOnDelete();
|
|
$table->string('certificate_no', 100)->unique()->nullable();
|
|
$table->string('file_path', 500)->nullable();
|
|
$table->string('token', 64)->unique();
|
|
$table->enum('status', ['pending', 'generating', 'generated', 'emailed', 'failed'])->default('pending');
|
|
$table->text('error_message')->nullable();
|
|
$table->timestamp('generated_at')->nullable();
|
|
$table->timestamp('emailed_at')->nullable();
|
|
$table->timestamp('downloaded_at')->nullable();
|
|
$table->unsignedInteger('download_count')->default(0);
|
|
$table->timestamps();
|
|
|
|
$table->unique(['program_id', 'participant_id']);
|
|
$table->index('token');
|
|
$table->index('status');
|
|
$table->index('program_id');
|
|
$table->index('participant_id');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('certificates');
|
|
}
|
|
};
|