fix migrations

parent 2d09e672
......@@ -27,7 +27,6 @@ public function up()
$table->dateTime('orm_requested_date')->nullable();
$table->integer('orm_approved_by_id')->nullable(); // FK → project_team.id
$table->dateTime('orm_approved_date')->nullable();
$table->timestamps();
$table->integer('updated_by')->nullable();
$table->softDeletes();
......
......@@ -8,46 +8,27 @@
{
public function up(): void
{
Schema::table('overtime_request_detail', function (Blueprint $table) {
if (!Schema::hasColumn('overtime_request_detail', 'ord_day_type')) {
$table->string('ord_day_type')->nullable()->after('ord_month_of_overtime');
}
if (!Schema::hasColumn('overtime_request_detail', 'ord_office_start')) {
$table->string('ord_office_start')->nullable()->after('ord_day_type');
}
if (!Schema::hasColumn('overtime_request_detail', 'ord_office_end')) {
$table->string('ord_office_end')->nullable()->after('ord_office_start');
}
if (!Schema::hasColumn('overtime_request_detail', 'ord_time_from')) {
$table->string('ord_time_from')->nullable()->after('ord_office_end');
}
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');
}
Schema::create('overtime_request_detail', function (Blueprint $table) {
$table->id();
$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();
$table->integer('ord_month_of_overtime')->nullable();
$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();
$table->decimal('ord_balance', 10, 2)->nullable();
$table->text('ord_reason')->nullable();
$table->decimal('ord_total_hours', 10, 2)->nullable();
$table->timestamps();
$table->integer('updated_by')->nullable();
$table->softDeletes();
});
}
public function down(): void
{
Schema::table('overtime_request_detail', function (Blueprint $table) {
$table->dropColumn([
'ord_day_type',
'ord_office_start',
'ord_office_end',
'ord_time_from',
'ord_time_to',
'ord_tasks',
]);
});
Schema::dropIfExists('overtime_request_detail');
}
};
\ No newline at end of file
......@@ -11,21 +11,20 @@ public function up(): void
Schema::create('overtime_claim_main', function (Blueprint $table) {
$table->id();
$table->string('ocm_apply_no')->nullable(); // e.g. OTC-202606-0001
$table->integer('ocm_name'); // FK → users.id (staff)
$table->date('ocm_date');
$table->tinyInteger('ocm_status')->default(1);
$table->string('ocm_project')->nullable();
$table->string('ocm_department')->nullable();
$table->string('ocm_position')->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->integer('fk_lkp_staff_info')->nullable();
$table->string('ocm_apply_no')->nullable();
$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_query_status')->nullable();
$table->integer('ocm_verified_by')->nullable();
$table->dateTime('ocm_verified_date')->nullable();
$table->integer('ocm_approved_by')->nullable();
$table->dateTime('ocm_approved_date')->nullable();
$table->dateTime('ocm_submit_date')->nullable();
$table->timestamps();
$table->integer('updated_by')->nullable();
$table->softDeletes();
......
......@@ -18,7 +18,6 @@ public function up()
$table->integer('fk_overtime_claim_main'); // FK → overtime_claim_main.id
$table->integer('fk_lkp_project')->nullable(); // FK → lkp_project.id
$table->dateTime('ocd_date')->nullable();
$table->string('ocd_day_type', 20)->nullable();
$table->string('ocd_office_hour', 30)->nullable();
......@@ -26,9 +25,7 @@ public function up()
$table->time('ocd_overtime_to')->nullable();
$table->text('ocd_tasks')->nullable();
$table->decimal('ocd_effective_hours', 10, 2)->default(0);
$table->decimal('ocd_total_hours', 10, 2)->default(0);
$table->timestamps();
$table->integer('updated_by')->nullable();
$table->softDeletes();
......
......@@ -9,7 +9,9 @@
public function up(): void
{
Schema::table('overtime_claim_main', function (Blueprint $table) {
$table->tinyInteger('ocm_query_status')->nullable()->after('ocm_status');
if (!Schema::hasColumn('overtime_claim_main', 'ocm_query_status')) {
$table->tinyInteger('ocm_query_status')->nullable()->after('ocm_status');
}
if (!Schema::hasColumn('overtime_claim_main', 'ocm_approved_by')) {
$table->integer('ocm_approved_by')->nullable()->after('ocm_query_status');
......
......@@ -378,6 +378,7 @@ public function addRequestFormDetail(int $mainId, $request): OvertimeRequestDeta
$detail = OvertimeRequestDetail::create([
'fk_overtime_request_main' => $mainId,
'ord_staff_id' => Auth::id(),
'ord_name' => $request->ord_name,
'ord_month_of_overtime' => $request->ord_month_of_overtime,
'ord_budgeted' => $budgeted,
......@@ -404,6 +405,7 @@ public function updateRequestFormDetail(int $detailId, $request): OvertimeReques
$balance = $budgeted - $utilised;
$detail->update([
'ord_staff_id' => Auth::id(),
'ord_name' => $request->ord_name,
'ord_month_of_overtime' => $request->ord_month_of_overtime,
'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