1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 11:44:03 +00:00

Add docblock to command, improve description and output messages

This commit is contained in:
lukinovec 2025-08-06 14:32:23 +02:00
parent 8619f18830
commit d2f55e620c

View file

@ -8,6 +8,11 @@ use Illuminate\Console\Command;
use Stancl\Tenancy\Features\UserImpersonation; use Stancl\Tenancy\Features\UserImpersonation;
/** /**
* This command clears expired impersonation tokens.
* By default, all tokens older than UserImpersonation::$ttl (60 seconds by default)
* are deleted. To override this, you can use the --ttl option, for example
* --ttl=120, all tokens older than 120 seconds will be deleted, ignoring the default.
*
* @see Stancl\Tenancy\Features\UserImpersonation * @see Stancl\Tenancy\Features\UserImpersonation
*/ */
class ClearExpiredImpersonationTokens extends Command class ClearExpiredImpersonationTokens extends Command
@ -15,11 +20,11 @@ class ClearExpiredImpersonationTokens extends Command
protected $signature = 'tenants:clear-expired-impersonation-tokens protected $signature = 'tenants:clear-expired-impersonation-tokens
{--ttl= : TTL in seconds for impersonation tokens (default is UserImpersonation::$ttl)}'; {--ttl= : TTL in seconds for impersonation tokens (default is UserImpersonation::$ttl)}';
protected $description = 'Remove expired impersonation tokens.'; protected $description = 'Clear expired impersonation tokens.';
public function handle(): int public function handle(): int
{ {
$this->components->info('Removing expired impersonation tokens.'); $this->components->info('Deleting expired impersonation tokens.');
$ttl = (int) $this->option('ttl') ?: UserImpersonation::$ttl; $ttl = (int) $this->option('ttl') ?: UserImpersonation::$ttl;
$expirationDate = now()->subSeconds($ttl); $expirationDate = now()->subSeconds($ttl);