From 6643411c439e1c0d1ddf97455ca6e7a4f5e15d3a Mon Sep 17 00:00:00 2001 From: Kekeocha Justin Chetachukwu <39213342+justinkekeocha@users.noreply.github.com> Date: Tue, 12 Sep 2023 13:22:31 +0100 Subject: [PATCH 1/2] feat: updateOrAddMeta for wallet It will be nice to have a method that updates or adds a new key to the meta. Just like what you did here: https://github.com/bavix/laravel-wallet/issues/498#issuecomment-1124005291 Signed-off-by: Kekeocha Justin Chetachukwu <39213342+justinkekeocha@users.noreply.github.com> --- src/Models/Wallet.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Models/Wallet.php b/src/Models/Wallet.php index 77c76f739..8afc824ea 100644 --- a/src/Models/Wallet.php +++ b/src/Models/Wallet.php @@ -158,6 +158,11 @@ public function getCurrencyAttribute(): string return $this->meta['currency'] ?? Str::upper($this->slug); } + public function updateOrAddMeta(array $array): array + { + return $this->meta = array_merge($this->meta ?? [], $array); + } + protected function initializeMorphOneWallet(): void { $this->uuid = app(UuidFactoryServiceInterface::class)->uuid4(); From 14be368621f88c5922fe98b04c3c71d716cac45a Mon Sep 17 00:00:00 2001 From: Kekeocha Justin Chetachukwu <39213342+justinkekeocha@users.noreply.github.com> Date: Tue, 12 Sep 2023 13:28:13 +0100 Subject: [PATCH 2/2] Update Wallet.php changed variable name Signed-off-by: Kekeocha Justin Chetachukwu <39213342+justinkekeocha@users.noreply.github.com> --- src/Models/Wallet.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Models/Wallet.php b/src/Models/Wallet.php index 8afc824ea..5727d3a25 100644 --- a/src/Models/Wallet.php +++ b/src/Models/Wallet.php @@ -158,9 +158,9 @@ public function getCurrencyAttribute(): string return $this->meta['currency'] ?? Str::upper($this->slug); } - public function updateOrAddMeta(array $array): array + public function updateOrAddMeta(array $meta): array { - return $this->meta = array_merge($this->meta ?? [], $array); + return $this->meta = array_merge($this->meta ?? [], $meta); } protected function initializeMorphOneWallet(): void