diff --git a/app/Livewire/Mailbox.php b/app/Livewire/Mailbox.php
index 82fff52..212cd0d 100644
--- a/app/Livewire/Mailbox.php
+++ b/app/Livewire/Mailbox.php
@@ -223,7 +223,7 @@ class Mailbox extends Component
'created_ip' => request()->ip(),
'last_accessed_ip' => request()->ip(),
'last_accessed_at' => now(),
- 'expires_at' => now()->addDays(7), // Default expiry
+ 'expires_at' => now()->addDays($this->getValidityDays()),
]);
$this->currentMailboxId = $mailbox->id;
@@ -262,7 +262,7 @@ class Mailbox extends Component
'created_ip' => request()->ip(),
'last_accessed_ip' => request()->ip(),
'last_accessed_at' => now(),
- 'expires_at' => now()->addDays(7),
+ 'expires_at' => now()->addDays($this->getValidityDays()),
]);
$this->currentMailboxId = $mailbox->id;
@@ -270,6 +270,27 @@ class Mailbox extends Component
Session::put('current_mailbox_id', $mailbox->id);
}
+ /**
+ * Get mailbox lifespan in days based on user tier.
+ * Guest: 1 day, Free: 3 days, Pro: 7 days, Enterprise: 14 days.
+ */
+ protected function getValidityDays(): int
+ {
+ $user = auth()->user();
+
+ if (! $user) {
+ return 1; // Guests get 24 hours
+ }
+
+ return match (true) {
+ $user->isEnterprise() => 14,
+ $user->isAdmin() => 14, // Assuming admins get enterprise limits
+ $user->isPro() => 7,
+ $user->isFree() => 3,
+ default => 3,
+ };
+ }
+
public function finishAutoCreation(): void
{
if ($this->getActiveMailboxesProperty()->isEmpty()) {
diff --git a/resources/views/livewire/mailbox.blade.php b/resources/views/livewire/mailbox.blade.php
index 0057257..2a06150 100644
--- a/resources/views/livewire/mailbox.blade.php
+++ b/resources/views/livewire/mailbox.blade.php
@@ -154,18 +154,58 @@
{{ $currentMailbox->address }}
-
+
Expires In
- {{ $currentMailbox->expires_at?->diffForHumans(['parts' => 2, 'short' => true]) ?? 'Never' }}
+
- @php
- $percent = $currentMailbox->expires_at
- ? max(0, min(100, (now()->diffInSeconds($currentMailbox->expires_at) / (86400 * 7)) * 100))
- : 100;
- @endphp
-
+
@@ -191,9 +231,43 @@
@if($mailbox->id !== $currentMailboxId)