Initial commit for combined ProjectKP

This commit is contained in:
raditarahman5-cloud
2026-06-28 15:14:51 +07:00
commit ac6c3473d4
203 changed files with 41848 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
*.sqlite*
@@ -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,
]);
}
}
@@ -0,0 +1,53 @@
<?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('username')->unique(); // <--- BARIS INI WAJIB ADA
$table->string('email')->unique();
$table->string('password');
$table->enum('role', ['superadmin', 'admin', 'user'])->default('user');
$table->string('jabatan')->nullable();
$table->timestamps();
});
// 2. Tabel Password Reset
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
// 3. Tabel Sessions (Penting untuk login)
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');
}
};
@@ -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->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -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');
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
$table->index(['queue', 'reserved_at', 'available_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->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,26 @@
<?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('pegawai', function (Blueprint $table) {
$table->id();
$table->string('nip')->unique();
$table->string('nama');
$table->string('jabatan');
$table->foreignId('user_id')->constrained('users')->onDelete('cascade');
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('pegawai');
}
};
@@ -0,0 +1,108 @@
<?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
{
/*
|--------------------------------------------------------------------------
| TABEL PENUGASAN
|--------------------------------------------------------------------------
*/
Schema::create('penugasan', function (Blueprint $table) {
$table->id();
$table->string('nomor_surat')
->unique()
->nullable();
$table->string('kegiatan');
$table->string('lokasi')->nullable();
$table->text('keterangan')->nullable();
$table->string('lampiran')->nullable();
$table->date('tanggal_mulai');
$table->date('tanggal_selesai')
->nullable();
$table->enum('status', [
'proses',
'selesai',
'telah_ditinjau',
'dibatalkan'
])->default('proses');
/*
|--------------------------------------------------------------------------
| FOREIGN KEY
|--------------------------------------------------------------------------
*/
$table->foreignId('created_by')
->constrained('users')
->onDelete('cascade');
$table->foreignId('approved_by')
->nullable()
->constrained('users')
->onDelete('set null');
$table->timestamp('approved_at')
->nullable();
/*
|--------------------------------------------------------------------------
| LAINNYA
|--------------------------------------------------------------------------
*/
$table->text('alasan_hapus')
->nullable();
$table->softDeletes();
$table->timestamps();
});
/*
|--------------------------------------------------------------------------
| TABEL PIVOT PENUGASAN PEGAWAI
|--------------------------------------------------------------------------
*/
Schema::create('penugasan_pegawai', function (Blueprint $table) {
$table->id();
$table->foreignId('penugasan_id')
->constrained('penugasan')
->onDelete('cascade');
// FIX DI SINI: Mereferensikan ke tabel users karena pegawai mengambil dari role user
$table->foreignId('pegawai_id')
->constrained('users')
->onDelete('cascade');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('penugasan_pegawai');
Schema::dropIfExists('penugasan');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('unit_kerjas', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('unit_kerjas');
}
};
@@ -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('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('notifications');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('penugasan', function (Blueprint $table) {
$table->text('status_note')->nullable()->after('status');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('penugasan', function (Blueprint $table) {
$table->dropColumn('status_note');
});
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('penugasan', function (Blueprint $table) {
$table->boolean('is_archived')->default(false)->after('status_note');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('penugasan', function (Blueprint $table) {
$table->dropColumn('is_archived');
});
}
};
@@ -0,0 +1,30 @@
<?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('penugasan_progress', function (Blueprint $table) {
$table->id();
$table->foreignId('penugasan_id')->constrained('penugasan')->onDelete('cascade');
$table->foreignId('user_id')->constrained('users')->onDelete('cascade');
$table->text('note');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('penugasan_progress');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('penugasan_progress', function (Blueprint $table) {
$table->string('attachment')->nullable()->after('note');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('penugasan_progress', function (Blueprint $table) {
$table->dropColumn('attachment');
});
}
};
+117
View File
@@ -0,0 +1,117 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
class AkunSeeder extends Seeder
{
public function run(): void
{
/*
|--------------------------------------------------------------------------
| SUPER ADMIN
|--------------------------------------------------------------------------
| Super Admin memiliki akses penuh terhadap sistem.
*/
User::updateOrCreate(
['username' => 'sutowo_superadmin'],
[
'name' => 'SUTOWO, SE, M.Si',
'email' => 'superadmin@mail.com',
'password' => Hash::make('password123'),
'role' => 'superadmin',
'jabatan' => 'Kepala Bidang Pengawasan Ketenagakerjaan',
]
);
/*
|--------------------------------------------------------------------------
| ADMIN
|--------------------------------------------------------------------------
| Admin hanya digunakan untuk membuat akun pegawai/user.
*/
$admins = [
[
'name' => 'WELPRIDA IRANI, SH, M.Si',
'username' => 'welprida_admin',
'email' => 'welprida@admin.com',
'jabatan' => 'Kepala Seksi Penegakan Hukum',
],
[
'name' => 'RINI YULIASTI, ST.,MM',
'username' => 'rini_admin',
'email' => 'rini@admin.com',
'jabatan' => 'Kasi Informasi Pasar Kerja dan Analisis Produktivitas',
],
];
foreach ($admins as $admin) {
User::updateOrCreate(
['username' => $admin['username']],
[
'name' => $admin['name'],
'email' => $admin['email'],
'password' => Hash::make('password123'),
'role' => 'admin',
'jabatan' => $admin['jabatan'],
]
);
}
/*
|--------------------------------------------------------------------------
| USER / PEGAWAI
|--------------------------------------------------------------------------
| Dalam database role disimpan sebagai "user".
| Di tampilan sistem boleh tetap ditulis sebagai "Pegawai".
*/
$pegawai = [
[
'name' => 'HARRI MULIAWAN, ST',
'username' => 'hari_disnaker',
'email' => 'harri@pegawai.com',
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Muda',
],
[
'name' => 'DANA OKTAVIAN, S.Sos',
'username' => 'dana_disnaker',
'email' => 'dana@pegawai.com',
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Muda',
],
[
'name' => 'LISBET MARYATI S, SH',
'username' => 'lisbet_disnaker',
'email' => 'lisbet@pegawai.com',
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
],
[
'name' => 'MAISA BAHARI, SH',
'username' => 'maisa_disnaker',
'email' => 'maisa@pegawai.com',
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
],
[
'name' => 'URAY NANDA KHARISMA, SE',
'username' => 'uray_disnaker',
'email' => 'uray@pegawai.com',
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
],
];
foreach ($pegawai as $user) {
User::updateOrCreate(
['username' => $user['username']],
[
'name' => $user['name'],
'email' => $user['email'],
'password' => Hash::make('password123'),
'role' => 'user',
'jabatan' => $user['jabatan'],
]
);
}
}
}
@@ -0,0 +1,15 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run(): void
{
$this->call([
AkunSeeder::class,
]);
}
}
@@ -0,0 +1,69 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class PegawaiSeeder extends Seeder
{
public function run(): void
{
// Matikan pengecekan foreign key sementara agar bisa truncate (bersihkan tabel)
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
DB::table('pegawais')->truncate();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
// Masukkan data pegawai saja (Profile), User ID disesuaikan dengan urutan di AkunSeeder
// ID 1: Sutowo, ID 2: Welprida, ID 3: Rini, ID 4: Harri ...
DB::table('pegawais')->insert([
[
'id' => 4,
'nip' => '198501012010011001',
'nama' => 'HARRI MULIAWAN, ST',
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Muda',
'user_id' => 4, // Nyambung ke Harri di tabel users
'created_at' => now(),
'updated_at' => now(),
],
[
'id' => 5,
'nip' => '198602022011021002',
'nama' => 'DANA OKTAVIAN, S.Sos',
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Muda',
'user_id' => 5,
'created_at' => now(),
'updated_at' => now(),
],
[
'id' => 6,
'nip' => '198703032012032003',
'nama' => 'LISBET MARYATI S, SH',
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
'user_id' => 6,
'created_at' => now(),
'updated_at' => now(),
],
[
'id' => 7,
'nip' => '198804042013042004',
'nama' => 'MAISA BAHARI, SH',
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
'user_id' => 7,
'created_at' => now(),
'updated_at' => now(),
],
[
'id' => 8,
'nip' => '198905052014051005',
'nama' => 'URAY NANDA KHARISMA, SE',
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
'user_id' => 8,
'created_at' => now(),
'updated_at' => now(),
],
]);
$this->command->info('✓ PegawaiSeeder Berhasil: Data profil pegawai sudah masuk!');
}
}