From e49dbfe45061ff27edd9c819284e2e3281a3570c Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Sat, 23 Nov 2024 13:17:50 +0500 Subject: [PATCH] wip --- .../Actions/MakePaymentNovaVisaMaster.php | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/app/Nova/Actions/MakePaymentNovaVisaMaster.php b/app/Nova/Actions/MakePaymentNovaVisaMaster.php index 6e3ecf3..ae7374d 100644 --- a/app/Nova/Actions/MakePaymentNovaVisaMaster.php +++ b/app/Nova/Actions/MakePaymentNovaVisaMaster.php @@ -44,13 +44,33 @@ class MakePaymentNovaVisaMaster extends Action public function handle(ActionFields $fields, Collection $models) { if (is_null($fields->payment_amount) || is_null($fields->usd_payment)) { - return ActionResponse::danger('Töleg maglumatlary ýok!'); + return Action::modal('modal-response', [ + 'title' => 'Töleg maglumatlary ýok!', + 'body' => 'Töleg maglumatlary girizilmedik', + ]); } $resource = $models->first(); + $hasBeenPaid = false; + $resource->items->each(function ($item) use ($hasBeenPaid) { + if (boolval($item->paid) && now()->format('m Y') == $item->created_at->format('m Y')) { + $hasBeenPaid = true; + } + }); + + if (! $hasBeenPaid) { + return Action::modal('modal-response', [ + 'title' => 'Bul aý töleg edildi!', + 'body' => 'Bul aý töleg edildi.', + ]); + } + if (! $resource->branch || ! $resource->branch->billing_visa_master_username) { - return ActionResponse::danger('Şahamça visa/master tölegi kabul edip bilmeýär.'); + return Action::modal('modal-response', [ + 'title' => 'Billing maglumatlary şahamçada ýok!', + 'body' => 'Şahamça visa/master tölegi kabul edip bilmeýär.', + ]); } $total_amount = floatval(number_format($fields->payment_amount, 2, '.', '')) + 23; @@ -62,7 +82,10 @@ class MakePaymentNovaVisaMaster extends Action $payment = $this->order($resource, $total_amount); if ($payment['status'] !== 'success') { - return ActionResponse::danger('Töleg ýerinde näsazlyk!'); + return Action::modal('modal-response', [ + 'title' => 'Töleg ýerinde näsazlyk!', + 'body' => 'Halkbank apida mesele bar.', + ]); } $this->createPaymentRecord($payment, $resource, $total_amount, $fields->usd_payment);