Tambah fitur riwayat permohonan

Menambahkan migrasi database, model, dan service untuk mencatat riwayat setiap permohonan. Migrasi menciptakan tabel `permohonan_histories` dengan menyimpan detail tentang status, keterangan, perubahan permohonan (sebelum dan sesudah), dan informasi file terkait. Model `PermohonanHistory` mengatur relasi dengan model `Permohonan` dan `User`. Service `PermohonanHistoryService` menangani pembuatan riwayat baru serta penanganan file terkait dan error handling yang memadai.
This commit is contained in:
Daeng Deni Mardaeni
2024-11-08 19:53:15 +07:00
parent 70344ff310
commit f3297988ff
3 changed files with 88 additions and 9 deletions

View File

@@ -4,20 +4,22 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('penilaian_team', function (Blueprint $table) {
Schema::create('permohonan_histories', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('penilaian_id');
$table->unsignedBigInteger('team_id');
$table->unsignedBigInteger('user_id');
$table->string('role');
$table->boolean('status')->default(true);
$table->char('authorized_status', 1)->nullable();
$table->unsignedBigInteger('permohonan_id');
$table->string('status');
$table->text('keterangan')->nullable();
$table->json('before_request')->nullable();
$table->json('after_request')->nullable();
$table->string('file_path')->nullable();
$table->unsignedBigInteger('user_id')->nullable();
$table->timestamps();
$table->timestamp('authorized_at')->nullable();
$table->unsignedBigInteger('authorized_by')->nullable();
@@ -25,6 +27,9 @@ return new class () extends Migration {
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
$table->foreign('permohonan_id')->references('id')->on('permohonan')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
});
}
@@ -33,6 +38,6 @@ return new class () extends Migration {
*/
public function down(): void
{
Schema::dropIfExists('penilai_team');
Schema::dropIfExists('permohonan_histories');
}
};