Page MenuHomePhorge

2021_02_19_100000_transaction_amount_fix.php
No OneTemporary

Authored By
Unknown
Size
878 B
Referenced Files
None
Subscribers
None

2021_02_19_100000_transaction_amount_fix.php

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
// phpcs:ignore
class TransactionAmountFix extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$negatives = [
\App\Transaction::WALLET_CHARGEBACK,
\App\Transaction::WALLET_DEBIT,
\App\Transaction::WALLET_PENALTY,
\App\Transaction::WALLET_REFUND,
];
$query = "UPDATE transactions SET amount = amount * -1"
. " WHERE type IN (" . implode(',', array_fill(0, count($negatives), '?')) . ")";
DB::select($query, $negatives);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::select("UPDATE transactions SET amount = amount * -1 WHERE amount < 0");
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Apr 4, 12:30 AM (4 w, 8 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ca/58/31efdb6868e95778eb3e6c9878c0
Default Alt Text
2021_02_19_100000_transaction_amount_fix.php (878 B)

Event Timeline