parfum/database/migrations/2025_09_13_034842_create_employees_table.php
Yoga Pangestu c4b90acf53 feat: membuat factory seluruh model
- menyesuaikan model jika ada yang salah seperti kurangnya trait SoftDeletes, casting yang salah, relasi yang kurang dan lainnya
- memperbaiki enum di migrasi
2025-12-09 08:25:07 +07:00

43 lines
1.4 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')->nullable();
$table->date('birthdate');
$table->date('hire_date');
$table->date('resign_date')->nullable();
$table->enum('status', EmploymentStatus::values())->default(EmploymentStatus::PERMANENT)->comment(EmploymentStatus::comment());
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('employees');
}
};