From 1290c19339d5f1775370a7dd2cc18b1d86f79be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 12 Feb 2024 18:55:03 +0100 Subject: [PATCH] Add Cart component and handle context in Purchase class --- app/Livewire/BillingPortal/Purchase.php | 21 ++++++++++----- .../billing-portal/v3/purchase.blade.php | 26 ++++++++++++------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/app/Livewire/BillingPortal/Purchase.php b/app/Livewire/BillingPortal/Purchase.php index baf6f41877a1..79da0873e018 100644 --- a/app/Livewire/BillingPortal/Purchase.php +++ b/app/Livewire/BillingPortal/Purchase.php @@ -13,6 +13,7 @@ namespace App\Livewire\BillingPortal; use App\Libraries\MultiDB; +use App\Livewire\BillingPortal\Cart\Cart; use App\Models\Subscription; use Livewire\Attributes\Computed; use Livewire\Attributes\On; @@ -26,6 +27,8 @@ class Purchase extends Component public array $request_data; + public string $hash; + public ?string $campaign; // @@ -34,6 +37,7 @@ class Purchase extends Component public array $steps = [ Setup::class, + Cart::class, Authentication::class, Example::class, ]; @@ -41,9 +45,14 @@ class Purchase extends Component public array $context = []; #[On('purchase.context')] - public function handleContext(string $property, $value): void + public function handleContext(string $property, $value): self { $this->context[$property] = $value; + + // The following may not be needed, as we can pass arround $context. + // cache()->set($this->hash, $this->context); + + return $this; } #[On('purchase.next')] @@ -70,11 +79,11 @@ class Purchase extends Component { MultiDB::setDb($this->db); - $this->context = [ - 'quantity' => 1, - 'request_data' => $this->request_data, - 'campaign' => $this->campaign, - ]; + $this + ->handleContext('hash', $this->hash) + ->handleContext('quantity', 1) + ->handleContext('request_data', $this->request_data) + ->handleContext('campaign', $this->campaign); } public function render() diff --git a/resources/views/billing-portal/v3/purchase.blade.php b/resources/views/billing-portal/v3/purchase.blade.php index 4d3a6950d8d8..07c738677d91 100644 --- a/resources/views/billing-portal/v3/purchase.blade.php +++ b/resources/views/billing-portal/v3/purchase.blade.php @@ -1,10 +1,14 @@ -
-
-
- +
+
+ {{ $subscription->company->present()->name }} + alt="{{ $subscription->company->present()->name }}" + /> +
@livewire($this->component, ['context' => $context, 'subscription' => $this->subscription], key($this->component)) @@ -12,9 +16,13 @@
-
-
-

{{ $subscription->name }}

+
+
+
+
+ +
+