mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 04:24:16 +00:00
transaction bill
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user