added migration to calculate base amount for payments table

This commit is contained in:
harshjagad20
2021-12-13 11:34:47 +05:30
parent b24350aba6
commit 6ce74bd59f

View File

@ -0,0 +1,34 @@
<?php
use Crater\Models\Payment;
use Illuminate\Database\Migrations\Migration;
class CalculateBaseAmountOfPaymentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$payments = Payment::all();
if ($payments) {
foreach ($payments as $payment) {
$payment->base_amount = $payment->exchange_rate * $payment->amount;
$payment->save();
}
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}