Skip to content

Commit 446c98d

Browse files
committed
retrieve license key from database
1 parent f87bee3 commit 446c98d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

app/Livewire/OrderSuccess.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace App\Livewire;
44

55
use App\Enums\Subscription;
6-
use Illuminate\Support\Facades\Cache;
6+
use App\Models\User;
77
use Laravel\Cashier\Cashier;
88
use Livewire\Attributes\Layout;
99
use Livewire\Attributes\Title;
@@ -63,11 +63,21 @@ private function loadLicenseKey(): ?string
6363
return null;
6464
}
6565

66-
if ($licenseKey = Cache::get($this->email.'.license_key')) {
67-
session()->put($this->sessionKey('license_key'), $licenseKey);
66+
$user = User::where('email', $this->email)->first();
67+
68+
if (! $user) {
69+
return null;
6870
}
6971

70-
return $licenseKey;
72+
$license = $user->licenses()->latest()->first();
73+
74+
if (! $license) {
75+
return null;
76+
}
77+
78+
session()->put($this->sessionKey('license_key'), $license->key);
79+
80+
return $license->key;
7181
}
7282

7383
private function loadSubscription(): ?Subscription

0 commit comments

Comments
 (0)