From f48e76eda0056ee0d288f10145bdcf2f411dd961 Mon Sep 17 00:00:00 2001 From: Aji Kamaludin Date: Tue, 4 Jul 2023 21:26:34 +0700 Subject: [PATCH] bitfix --- TODO.md | 2 ++ .../Customer/DepositController.php | 1 + .../Customer/PaylaterController.php | 2 ++ app/Models/DepositHistory.php | 32 +++++++++++++++++++ .../DetailPartials/FormUploadCashDeposit.jsx | 2 +- .../DetailPartials/FormUploadManual.jsx | 2 +- 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 3c9b930..b434ffa 100644 --- a/TODO.md +++ b/TODO.md @@ -2,6 +2,8 @@ ## Note +- [ ] expired point + ## Front # Back Office diff --git a/app/Http/Controllers/Customer/DepositController.php b/app/Http/Controllers/Customer/DepositController.php index 3f3ece7..b4f5cde 100644 --- a/app/Http/Controllers/Customer/DepositController.php +++ b/app/Http/Controllers/Customer/DepositController.php @@ -131,6 +131,7 @@ class DepositController extends Controller ]); $deposit->create_notification(); + $deposit->create_notification_repayment(); session()->flash('message', ['type' => 'success', 'message' => 'Upload berhasil, silahkan tunggu untuk approve']); } diff --git a/app/Http/Controllers/Customer/PaylaterController.php b/app/Http/Controllers/Customer/PaylaterController.php index d5b8701..ec5a8e6 100644 --- a/app/Http/Controllers/Customer/PaylaterController.php +++ b/app/Http/Controllers/Customer/PaylaterController.php @@ -130,6 +130,8 @@ class PaylaterController extends Controller $deposit->update(['payment_token' => $token]); } + $deposit->create_notification_repayment(); + $paylater->save(); DB::commit(); diff --git a/app/Models/DepositHistory.php b/app/Models/DepositHistory.php index 23122a2..207405b 100644 --- a/app/Models/DepositHistory.php +++ b/app/Models/DepositHistory.php @@ -160,6 +160,10 @@ class DepositHistory extends Model public function create_notification() { + if ($this->type != self::TYPE_DEPOSIT) { + return; + } + if ($this->payment_channel == Setting::PAYMENT_MANUAL) { $status = ''; if ($this->is_valid == self::STATUS_WAIT_APPROVE) { @@ -197,6 +201,34 @@ class DepositHistory extends Model ]); } + + NotificationEvent::dispatch([ + 'id' => $notification->id, + 'description' => $notification->description, + 'url' => $notification->url, + 'type' => Notification::TYPE_DEPOSIT, + 'format_created_at' => now()->translatedFormat('d F Y H:i:s'), + 'deposit_notifications' => Notification::where('entity_type', User::class) + ->where('type', Notification::TYPE_DEPOSIT) + ->where('is_read', Notification::UNREAD)->limit(10) + ->orderBy('created_at', 'desc') + ->get(), + ]); + } + + public function create_notification_repayment() + { + if ($this->type != self::TYPE_REPAYMENT) { + return; + } + + $notification = Notification::create([ + 'entity_type' => User::class, + 'description' => $this->customer->fullname . ' melakukan pembayaran hutang sebesar ' . $this->amount, + 'url' => route('paylater.repay.edit', $this), + 'type' => Notification::TYPE_DEPOSIT, + ]); + NotificationEvent::dispatch([ 'id' => $notification->id, 'description' => $notification->description, diff --git a/resources/js/Customer/Deposit/DetailPartials/FormUploadCashDeposit.jsx b/resources/js/Customer/Deposit/DetailPartials/FormUploadCashDeposit.jsx index 5540b31..1b51178 100644 --- a/resources/js/Customer/Deposit/DetailPartials/FormUploadCashDeposit.jsx +++ b/resources/js/Customer/Deposit/DetailPartials/FormUploadCashDeposit.jsx @@ -256,7 +256,7 @@ export const FormUploadCashDeposit = () => { bukti Pembayaran )} diff --git a/resources/js/Customer/Deposit/DetailPartials/FormUploadManual.jsx b/resources/js/Customer/Deposit/DetailPartials/FormUploadManual.jsx index f121c45..dc24b42 100644 --- a/resources/js/Customer/Deposit/DetailPartials/FormUploadManual.jsx +++ b/resources/js/Customer/Deposit/DetailPartials/FormUploadManual.jsx @@ -232,7 +232,7 @@ export const FormUploadManual = () => { {isEmpty(data.image_url) == false && ( bukti transfer