fix bill seeder

This commit is contained in:
omair saleh
2022-02-18 09:47:30 +08:00
parent 9f89b87249
commit aa3d50e125
2 changed files with 13 additions and 13 deletions
@@ -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();
}))
];
}
}