parfum/database/migrations/2025_09_13_034842_create_employees_table.php
Yoga Pangestu c2e2b85070 feat(user): fitur user dan employee
-crud
-membuat fungsi untuk generate kode pegawai di model Employee
-menyesuaikan migrasi users dan employees
-menyesuaikan value seeder dengan migrasi baru
2025-09-24 19:38:59 +07:00

42 lines
1.3 KiB
PHP

<?php
use App\Enums\EmploymentStatus;
use App\Enums\Gender;
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('employees', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('full_name', 100);
$table->string('code', 20)->unique();
$table->string('phone_number', 20);
$table->unsignedInteger('base_salary')->default(0);
$table->enum('gender', [Gender::values()])->comment(Gender::comment());
$table->text('address');
$table->date('birthdate');
$table->date('hire_date');
$table->date('resign_date')->nullable();
$table->enum('status', [EmploymentStatus::values()])->default(EmploymentStatus::PERMANENT)->comment(EmploymentStatus::comment());
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('employees');
}
};