- menyesuaikan model jika ada yang salah seperti kurangnya trait SoftDeletes, casting yang salah, relasi yang kurang dan lainnya - memperbaiki enum di migrasi
43 lines
1.4 KiB
PHP
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');
|
|
}
|
|
};
|