fix bill seeder

This commit is contained in:
omair saleh
2022-02-18 09:53:10 +08:00
parent aa3d50e125
commit 1e2b039ba8
2 changed files with 2 additions and 13 deletions
+1 -5
View File
@@ -57,11 +57,7 @@ class BookingResource extends JsonResource
'expired_payment_attempts' => TransactionResource::collection($this->transactions()->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '<', Carbon::now())->get()),
'payment_history' => TransactionResource::collection($this->transactions()->where(function($query){
$query->where(function($query){
$query->where(function($query){
$query->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED]);
})->orWhere(function($query){
$query->where('type', TransactionType::BILL)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
});
$query->payments();
})->orWhere(function($query){
$query->where(function($query){
$query->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::REJECTED, ApprovalStatus::COMPLETED]);
+1 -8
View File
@@ -41,14 +41,7 @@ class TransactionResource extends JsonResource
'interval' => [
'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();
}))
]
];
}
}