feat(mailbox): Implement tier-based dynamic expiration with real-time Alpine.js countdown
This commit is contained in:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user