fix migrations

parent 2d09e672
...@@ -27,7 +27,6 @@ public function up() ...@@ -27,7 +27,6 @@ public function up()
$table->dateTime('orm_requested_date')->nullable(); $table->dateTime('orm_requested_date')->nullable();
$table->integer('orm_approved_by_id')->nullable(); // FK → project_team.id $table->integer('orm_approved_by_id')->nullable(); // FK → project_team.id
$table->dateTime('orm_approved_date')->nullable(); $table->dateTime('orm_approved_date')->nullable();
$table->timestamps(); $table->timestamps();
$table->integer('updated_by')->nullable(); $table->integer('updated_by')->nullable();
$table->softDeletes(); $table->softDeletes();
......
...@@ -8,46 +8,27 @@ ...@@ -8,46 +8,27 @@
{ {
public function up(): void public function up(): void
{ {
Schema::table('overtime_request_detail', function (Blueprint $table) { Schema::create('overtime_request_detail', function (Blueprint $table) {
$table->id();
if (!Schema::hasColumn('overtime_request_detail', 'ord_day_type')) {
$table->string('ord_day_type')->nullable()->after('ord_month_of_overtime'); $table->integer('fk_overtime_request_main')->nullable(); // FK → overtime_request_main.id
} $table->integer('ord_staff_id')->nullable(); // FK → users.id
$table->string('ord_name')->nullable();
if (!Schema::hasColumn('overtime_request_detail', 'ord_office_start')) { $table->integer('ord_month_of_overtime')->nullable();
$table->string('ord_office_start')->nullable()->after('ord_day_type'); $table->decimal('ord_budgeted', 10, 2)->nullable();
} $table->decimal('ord_utilised_to_date', 10, 2)->nullable();
$table->decimal('ord_planned_ot_hour', 10, 2)->nullable();
if (!Schema::hasColumn('overtime_request_detail', 'ord_office_end')) { $table->decimal('ord_balance', 10, 2)->nullable();
$table->string('ord_office_end')->nullable()->after('ord_office_start'); $table->text('ord_reason')->nullable();
} $table->decimal('ord_total_hours', 10, 2)->nullable();
$table->timestamps();
if (!Schema::hasColumn('overtime_request_detail', 'ord_time_from')) { $table->integer('updated_by')->nullable();
$table->string('ord_time_from')->nullable()->after('ord_office_end'); $table->softDeletes();
}
if (!Schema::hasColumn('overtime_request_detail', 'ord_time_to')) {
$table->string('ord_time_to')->nullable()->after('ord_time_from');
}
if (!Schema::hasColumn('overtime_request_detail', 'ord_tasks')) {
$table->text('ord_tasks')->nullable()->after('ord_time_to');
}
}); });
} }
public function down(): void public function down(): void
{ {
Schema::table('overtime_request_detail', function (Blueprint $table) { Schema::dropIfExists('overtime_request_detail');
$table->dropColumn([
'ord_day_type',
'ord_office_start',
'ord_office_end',
'ord_time_from',
'ord_time_to',
'ord_tasks',
]);
});
} }
}; };
\ No newline at end of file
...@@ -11,21 +11,20 @@ public function up(): void ...@@ -11,21 +11,20 @@ public function up(): void
Schema::create('overtime_claim_main', function (Blueprint $table) { Schema::create('overtime_claim_main', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('ocm_apply_no')->nullable(); // e.g. OTC-202606-0001 $table->integer('fk_lkp_staff_info')->nullable();
$table->integer('ocm_name'); // FK → users.id (staff) $table->string('ocm_apply_no')->nullable();
$table->date('ocm_date'); $table->string('ocm_staff_employee_code')->nullable();
$table->string('ocm_staff_name')->nullable();
$table->integer('ocm_division')->nullable();
$table->integer('ocm_month')->nullable();
$table->integer('ocm_year')->nullable();
$table->tinyInteger('ocm_status')->default(1); $table->tinyInteger('ocm_status')->default(1);
$table->tinyInteger('ocm_query_status')->nullable();
$table->string('ocm_project')->nullable(); $table->integer('ocm_verified_by')->nullable();
$table->string('ocm_department')->nullable(); $table->dateTime('ocm_verified_date')->nullable();
$table->string('ocm_position')->nullable(); $table->integer('ocm_approved_by')->nullable();
$table->integer('ocm_requested_by_id')->nullable(); // FK → users.id
$table->dateTime('ocm_requested_date')->nullable();
$table->integer('ocm_approved_by_id')->nullable(); // FK → users.id
$table->dateTime('ocm_approved_date')->nullable(); $table->dateTime('ocm_approved_date')->nullable();
$table->dateTime('ocm_submit_date')->nullable();
$table->timestamps(); $table->timestamps();
$table->integer('updated_by')->nullable(); $table->integer('updated_by')->nullable();
$table->softDeletes(); $table->softDeletes();
......
...@@ -18,7 +18,6 @@ public function up() ...@@ -18,7 +18,6 @@ public function up()
$table->integer('fk_overtime_claim_main'); // FK → overtime_claim_main.id $table->integer('fk_overtime_claim_main'); // FK → overtime_claim_main.id
$table->integer('fk_lkp_project')->nullable(); // FK → lkp_project.id $table->integer('fk_lkp_project')->nullable(); // FK → lkp_project.id
$table->dateTime('ocd_date')->nullable(); $table->dateTime('ocd_date')->nullable();
$table->string('ocd_day_type', 20)->nullable(); $table->string('ocd_day_type', 20)->nullable();
$table->string('ocd_office_hour', 30)->nullable(); $table->string('ocd_office_hour', 30)->nullable();
...@@ -26,9 +25,7 @@ public function up() ...@@ -26,9 +25,7 @@ public function up()
$table->time('ocd_overtime_to')->nullable(); $table->time('ocd_overtime_to')->nullable();
$table->text('ocd_tasks')->nullable(); $table->text('ocd_tasks')->nullable();
$table->decimal('ocd_effective_hours', 10, 2)->default(0); $table->decimal('ocd_effective_hours', 10, 2)->default(0);
$table->decimal('ocd_total_hours', 10, 2)->default(0); $table->decimal('ocd_total_hours', 10, 2)->default(0);
$table->timestamps(); $table->timestamps();
$table->integer('updated_by')->nullable(); $table->integer('updated_by')->nullable();
$table->softDeletes(); $table->softDeletes();
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
public function up(): void public function up(): void
{ {
Schema::table('overtime_claim_main', function (Blueprint $table) { Schema::table('overtime_claim_main', function (Blueprint $table) {
if (!Schema::hasColumn('overtime_claim_main', 'ocm_query_status')) {
$table->tinyInteger('ocm_query_status')->nullable()->after('ocm_status'); $table->tinyInteger('ocm_query_status')->nullable()->after('ocm_status');
}
if (!Schema::hasColumn('overtime_claim_main', 'ocm_approved_by')) { if (!Schema::hasColumn('overtime_claim_main', 'ocm_approved_by')) {
$table->integer('ocm_approved_by')->nullable()->after('ocm_query_status'); $table->integer('ocm_approved_by')->nullable()->after('ocm_query_status');
......
...@@ -378,6 +378,7 @@ public function addRequestFormDetail(int $mainId, $request): OvertimeRequestDeta ...@@ -378,6 +378,7 @@ public function addRequestFormDetail(int $mainId, $request): OvertimeRequestDeta
$detail = OvertimeRequestDetail::create([ $detail = OvertimeRequestDetail::create([
'fk_overtime_request_main' => $mainId, 'fk_overtime_request_main' => $mainId,
'ord_staff_id' => Auth::id(),
'ord_name' => $request->ord_name, 'ord_name' => $request->ord_name,
'ord_month_of_overtime' => $request->ord_month_of_overtime, 'ord_month_of_overtime' => $request->ord_month_of_overtime,
'ord_budgeted' => $budgeted, 'ord_budgeted' => $budgeted,
...@@ -404,6 +405,7 @@ public function updateRequestFormDetail(int $detailId, $request): OvertimeReques ...@@ -404,6 +405,7 @@ public function updateRequestFormDetail(int $detailId, $request): OvertimeReques
$balance = $budgeted - $utilised; $balance = $budgeted - $utilised;
$detail->update([ $detail->update([
'ord_staff_id' => Auth::id(),
'ord_name' => $request->ord_name, 'ord_name' => $request->ord_name,
'ord_month_of_overtime' => $request->ord_month_of_overtime, 'ord_month_of_overtime' => $request->ord_month_of_overtime,
'ord_budgeted' => $budgeted, 'ord_budgeted' => $budgeted,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment