chore: initial Laravel 13 project setup for eCert MBIP
- 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>
This commit is contained in:
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
45
database/factories/UserFactory.php
Normal file
45
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
50
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
50
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->boolean('is_admin')->default(true);
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
59
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
59
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedSmallInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->string('connection');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
|
||||
$table->index(['connection', 'queue', 'failed_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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('programs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('organizer');
|
||||
$table->string('location', 500);
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
$table->dateTime('checkin_start_at')->nullable();
|
||||
$table->dateTime('checkin_end_at')->nullable();
|
||||
$table->dateTime('ecert_download_start_at')->nullable();
|
||||
$table->dateTime('ecert_download_end_at')->nullable();
|
||||
$table->enum('status', ['draft', 'published', 'closed'])->default('draft');
|
||||
$table->boolean('allow_walk_in')->default(true);
|
||||
$table->enum('default_staff_session', ['pagi', 'petang', 'full_day'])->nullable();
|
||||
$table->enum('default_external_session', ['pagi', 'petang', 'full_day'])->nullable();
|
||||
$table->foreignId('created_by')->constrained('users')->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('status');
|
||||
$table->index('uuid');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('programs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('program_qr_codes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('program_id')->constrained('programs')->cascadeOnDelete();
|
||||
$table->string('token', 64)->unique();
|
||||
$table->string('qr_image_path', 500)->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('token');
|
||||
$table->index('program_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('program_qr_codes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('participants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('name');
|
||||
$table->string('no_kp', 20)->unique();
|
||||
$table->string('email', 255)->nullable();
|
||||
$table->string('phone', 20)->nullable();
|
||||
$table->string('agency', 255)->nullable();
|
||||
$table->enum('participant_type', ['staff', 'external'])->default('external');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('no_kp');
|
||||
$table->index('email');
|
||||
$table->index('uuid');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('participants');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('program_participants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('program_id')->constrained('programs')->cascadeOnDelete();
|
||||
$table->foreignId('participant_id')->constrained('participants')->cascadeOnDelete();
|
||||
$table->enum('registration_source', ['pre_registered', 'walk_in', 'admin_manual', 'import'])->default('admin_manual');
|
||||
$table->boolean('is_pre_registered')->default(false);
|
||||
$table->enum('pre_registered_session', ['pagi', 'petang', 'full_day'])->nullable();
|
||||
$table->enum('status', ['registered', 'checked_in', 'cancelled'])->default('registered');
|
||||
$table->timestamp('registered_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['program_id', 'participant_id']);
|
||||
$table->index('program_id');
|
||||
$table->index('participant_id');
|
||||
$table->index('status');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('program_participants');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('attendances', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('program_id')->constrained('programs')->cascadeOnDelete();
|
||||
$table->foreignId('participant_id')->constrained('participants')->cascadeOnDelete();
|
||||
$table->foreignId('program_participant_id')->nullable()->constrained('program_participants')->nullOnDelete();
|
||||
$table->enum('attendance_source', ['pre_registered_staff', 'walk_in_external', 'admin_manual']);
|
||||
$table->enum('attendance_session', ['pagi', 'petang', 'full_day']);
|
||||
$table->timestamp('checked_in_at');
|
||||
$table->string('checked_in_ip', 45)->nullable();
|
||||
$table->string('user_agent', 500)->nullable();
|
||||
$table->string('notes', 500)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['program_id', 'participant_id']);
|
||||
$table->index('program_id');
|
||||
$table->index('participant_id');
|
||||
$table->index('attendance_source');
|
||||
$table->index('attendance_session');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('attendances');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('certificate_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('program_id')->constrained('programs')->cascadeOnDelete();
|
||||
$table->string('original_filename', 255);
|
||||
$table->string('image_path', 500);
|
||||
$table->json('config_json')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->foreignId('uploaded_by')->constrained('users');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('program_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('certificate_templates');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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('questionnaire_sets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title', 255);
|
||||
$table->text('description')->nullable();
|
||||
$table->enum('status', ['draft', 'published', 'archived'])->default('draft');
|
||||
$table->foreignId('created_by')->constrained('users');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('status');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('questionnaire_sets');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('questionnaire_questions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('questionnaire_set_id')->constrained('questionnaire_sets')->cascadeOnDelete();
|
||||
$table->text('question_text');
|
||||
$table->enum('question_type', ['rating', 'single_choice', 'multiple_choice', 'short_text', 'long_text']);
|
||||
$table->json('options_json')->nullable();
|
||||
$table->boolean('is_required')->default(true);
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['questionnaire_set_id', 'sort_order']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('questionnaire_questions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('program_questionnaires', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('program_id')->constrained('programs')->cascadeOnDelete();
|
||||
$table->foreignId('questionnaire_set_id')->constrained('questionnaire_sets');
|
||||
$table->boolean('is_confirmed')->default(false);
|
||||
$table->timestamp('confirmed_at')->nullable();
|
||||
$table->foreignId('confirmed_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['program_id', 'questionnaire_set_id']);
|
||||
$table->index('program_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('program_questionnaires');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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('questionnaire_responses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('program_id')->constrained('programs')->cascadeOnDelete();
|
||||
$table->foreignId('participant_id')->constrained('participants')->cascadeOnDelete();
|
||||
$table->foreignId('questionnaire_set_id')->constrained('questionnaire_sets');
|
||||
$table->timestamp('submitted_at');
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->string('user_agent', 500)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['program_id', 'participant_id', 'questionnaire_set_id'], 'unique_program_participant_questionnaire');
|
||||
$table->index('program_id');
|
||||
$table->index('participant_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('questionnaire_responses');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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('questionnaire_answers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('questionnaire_response_id')->constrained('questionnaire_responses')->cascadeOnDelete();
|
||||
$table->foreignId('questionnaire_question_id')->constrained('questionnaire_questions')->cascadeOnDelete();
|
||||
$table->json('answer_value')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('questionnaire_response_id');
|
||||
$table->index('questionnaire_question_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('questionnaire_answers');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
Schema::create('email_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('program_id')->nullable()->constrained('programs')->nullOnDelete();
|
||||
$table->foreignId('participant_id')->nullable()->constrained('participants')->nullOnDelete();
|
||||
$table->foreignId('certificate_id')->nullable()->constrained('certificates')->nullOnDelete();
|
||||
$table->string('recipient_email', 255);
|
||||
$table->string('subject', 500);
|
||||
$table->enum('email_type', ['certificate_ready', 'reminder', 'test'])->default('certificate_ready');
|
||||
$table->enum('status', ['pending', 'sent', 'failed'])->default('pending');
|
||||
$table->text('error_message')->nullable();
|
||||
$table->timestamp('sent_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('status');
|
||||
$table->index('program_id');
|
||||
$table->index('participant_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('email_logs');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('audit_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->string('action', 100);
|
||||
$table->string('auditable_type', 255)->nullable();
|
||||
$table->unsignedBigInteger('auditable_id')->nullable();
|
||||
$table->json('old_values')->nullable();
|
||||
$table->json('new_values')->nullable();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->string('user_agent', 500)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('user_id');
|
||||
$table->index('action');
|
||||
$table->index(['auditable_type', 'auditable_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('audit_logs');
|
||||
}
|
||||
};
|
||||
24
database/seeders/AdminSeeder.php
Normal file
24
database/seeders/AdminSeeder.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AdminSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
User::firstOrCreate(
|
||||
['email' => 'admin@mbip.gov.my'],
|
||||
[
|
||||
'name' => 'Admin eCert MBIP',
|
||||
'password' => Hash::make('Admin@MBIP2025!'),
|
||||
'is_admin' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->command->info('Admin account created: admin@mbip.gov.my / Admin@MBIP2025!');
|
||||
}
|
||||
}
|
||||
18
database/seeders/DatabaseSeeder.php
Normal file
18
database/seeders/DatabaseSeeder.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$this->call(AdminSeeder::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user