resolved conflicts

This commit is contained in:
2025-03-31 03:46:05 +03:00
6454 changed files with 1520539 additions and 9 deletions
@@ -0,0 +1,37 @@
<?php
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('cancer_protocols', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->integer('protocol_billing_type');
$table->integer('protocol_cost')->default(0)->nullable();
$table->text('pre_chemo_comments');
$table->longText('pre_chemo_drugs');
$table->text('chemo_comments');
$table->longText('chemo_drugs');
$table->text('post_chemo_comments');
$table->longText('post_chemo_drugs');
$table->integer('created_by');
$table->integer('updated_by')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void {
Schema::dropIfExists('cancer_protocols');
}
};
@@ -0,0 +1,101 @@
<?php
use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$debtors = DB::table('debtor_payments')->get();
DB::beginTransaction();
try {
Schema::table('debtor_payments', function (Blueprint $table) {
$table->integer('received_id')->nullable();
$table->integer('received_amount')->nullable();
$table->integer('banked_id')->nullable();
$table->date('date_paid')->nullable();
$table->string('comment')->nullable();
$table->string('receipt_number')->nullable();
$table->integer('amount_written_off')->nullable()->change();
$table->dropColumn([
'banked', 'received_amount_history', 'received_id_history', 'receipt_no', 'date',
'banked_history', 'amount_paid_history', 'date_paid_history', 'staff_in_charge_history',
'comment_history', 'receipt_history', 'balance_history', 'amount_owed', 'amount_written_off_history',
'amount_written_off_by_history', 'amount_written_off_at_history', 'patient_id'
]);
});
foreach ($debtors as $debtor) {
if (!is_null($debtor->amount_paid_history)) {
$amount_paid_history_arr = unserialize($debtor->amount_paid_history);
$comment_history_arr = unserialize($debtor->comment_history);
$staff_in_charge_history_arr = unserialize($debtor->staff_in_charge_history);
$receipt_history_arr = unserialize($debtor->receipt_history);
$balance_history_arr = unserialize($debtor->balance_history);
$date_paid_history_arr = unserialize($debtor->date_paid_history);
$amount_paid_history_arr = is_array($amount_paid_history_arr) ? array_values($amount_paid_history_arr) : [];
$comment_history_arr = is_array($comment_history_arr) ? array_values($comment_history_arr) : [];
$staff_in_charge_history_arr = is_array($staff_in_charge_history_arr) ? array_values($staff_in_charge_history_arr) : [];
$receipt_history_arr = is_array($receipt_history_arr) ? array_values($receipt_history_arr) : [];
$balance_history_arr = is_array($balance_history_arr) ? array_values($balance_history_arr) : [];
$date_paid_history_arr = is_array($date_paid_history_arr) ? array_values($date_paid_history_arr) : [];
$received_amount_history_arr = is_null($debtor->received_amount_history) ? [] : array_values(unserialize($debtor->received_amount_history));
$received_id_history_arr = is_null($debtor->received_id_history) ? [] : array_values(unserialize($debtor->received_id_history));
$banked_history_arr = is_null($debtor->banked_history) ? [] : array_values(unserialize($debtor->banked_history));
for ($i = 0; $i < count($amount_paid_history_arr); $i++) {
DB::table('debtor_payments')->insert([
'debt_id' => $debtor->debt_id, 'created_by' => $staff_in_charge_history_arr[$i] ?? $debtor->created_by, 'created_at' => $debtor->created_at,
'updated_at' => $debtor->updated_at, 'amount_paid' => $amount_paid_history_arr[$i] ?? 0,
'receipt_number' => $receipt_history_arr[$i] ?? '', 'banked_id' => $banked_history_arr[$i] ?? null,
'balance' => $balance_history_arr[$i] ?? 0, 'comment' => $comment_history_arr[$i] ?? '',
'date_paid' => $date_paid_history_arr[$i] ? Carbon::parse($date_paid_history_arr[$i])->toDateString() : Carbon::parse($debtor->created_at)->toDateString(),
'received_id' => $received_id_history_arr[$i] ?? null, 'received_amount' => $received_amount_history_arr[$i] ?? null,
]);
}
}
if (!is_null($debtor->amount_written_off_history)) {
$amount_written_off = json_decode($debtor->amount_written_off_history);
$amount_written_off_by = json_decode($debtor->amount_written_off_by_history);
$amount_written_off_at = json_decode($debtor->amount_written_off_at_history);
for ($i = 0; $i < count($amount_written_off); $i++) {
DB::table('debtor_payments')->insert([
'debt_id' => $debtor->debt_id, 'created_by' => $amount_written_off_by[$i], 'created_at' => $amount_written_off_at[$i],
'updated_at' => $debtor->updated_at, 'amount_paid' => $amount_written_off[$i],
'balance' => 0, 'amount_written_off' => $amount_written_off[$i],
'date_paid' => Carbon::parse($amount_written_off_at[$i])->toDateString(),
]);
}
}
DB::table('debtor_payments')->where('id', $debtor->id)->delete();
}
DB::commit();
} catch (\Exception $e) {
echo $e->getMessage();
DB::rollback();
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};