You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
625 B

<?php
namespace App\Console\Commands;
use App\Models\Admin;
use Illuminate\Console\Command;
class RevokeAdminTokens extends Command
{
protected $signature = 'admin:revoke-tokens';
protected $description = 'Revoke all existing administrator API tokens';
public function handle(): int
{
$count = 0;
Admin::query()->chunkById(100, function ($admins) use (&$count) {
foreach ($admins as $admin) {
$count += $admin->tokens()->delete();
}
});
$this->info("Revoked {$count} administrator token(s).");
return self::SUCCESS;
}
}