mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-23 22:44:03 +00:00
fix bill seeder
This commit is contained in:
@@ -42,6 +42,13 @@ class TransactionResource extends JsonResource
|
||||
'value' => (Carbon::parse($this->created_at)->addDays(3)->gt(Carbon::now()) ) ? '+' : '-' ,
|
||||
'duration' => Carbon::parse($this->created_at)->addDays(3)->diff(Carbon::now())->format('%d'),
|
||||
],
|
||||
new TransactionResource($this->when((int) $this->type === TransactionType::BILL, function(){
|
||||
$key = 0;
|
||||
$bills = $this->booking->transactions()->bills()->where('original_amount', '=', $this->original_amount)->get();
|
||||
if(count($bills) > 1){ $key = $bills->search(function($bill){ return $bill->id === $this->id; }); }
|
||||
return $this->booking->transactions()->payments()->complete()->where('original_amount', '=', $this->original_amount)->skip($key)->first();
|
||||
|
||||
}))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,15 +8,6 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateTransactionBillOwnerSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* StatesTableSeeder constructor.
|
||||
* @param FetchesCountry $fetchesCountry
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
@@ -29,11 +20,13 @@ class UpdateTransactionBillOwnerSeeder extends Seeder
|
||||
$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();
|
||||
$key = 0;
|
||||
$bills = $row->booking->transactions()->bills()->where('original_amount', '=', $row->original_amount)->get();
|
||||
if(count($bills) > 1){ $key = $bills->search(function($bill)use($row){ return $bill->id === $row->id; }); }
|
||||
$paymentTransaction = $row->booking->transactions()->payments()->complete()->where('original_amount', '=', $row->original_amount)->skip($key)->first();
|
||||
|
||||
$row->owner_type = 'App\Models\Transaction';
|
||||
$row->owner_id = $payment_trsanction->id;
|
||||
$row->owner_type = Transaction::class;
|
||||
$row->owner_id = $paymentTransaction->id;
|
||||
$row->update();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user