mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-25 15:34:02 +00:00
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
use App\Models\Transaction;
|
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class UpdateTransactionBillOwnerSeeder extends Seeder
|
|
{
|
|
/**
|
|
* StatesTableSeeder constructor.
|
|
* @param FetchesCountry $fetchesCountry
|
|
*/
|
|
public function __construct()
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
DB::beginTransaction();
|
|
|
|
$transaction = Transaction::where('type', TransactionType::BILL)->get();
|
|
|
|
foreach ($transaction as $key => $row) {
|
|
$booking = $row->booking()->first();
|
|
$payment_trsanction = $row->booking()->first()->transactions()->payments()->complete()->where('original_amount', '=', $row->original_amount)->where('id', '<', $row->id)->orderByDesc('id')->first();
|
|
|
|
$row->owner_type = 'App\Models\Transaction';
|
|
$row->owner_id = $payment_trsanction->id;
|
|
$row->update();
|
|
}
|
|
|
|
DB::commit();
|
|
}
|
|
}
|