ClearResetsCommand.php
TLDR
This file defines a command class called ClearResetsCommand
in the Illuminate\Auth\Console
namespace. The command is used to flush expired password reset tokens.
Methods
handle
This method is responsible for executing the console command. It retrieves the password broker for the given name (if provided) and deletes expired reset tokens. After deleting the expired tokens, it outputs a success message.
Classes
ClearResetsCommand
This command class extends the Illuminate\Console\Command
class. It is used to flush expired password reset tokens. The ClearResetsCommand
class has the following properties:
-
$signature
: The name and signature of the console command (auth:clear-resets
) -
$description
: The console command description (Flush expired password reset tokens
)
<?php
namespace Illuminate\Auth\Console;
use Illuminate\Console\Command;
use Symfony\Component\Console\Attribute\AsCommand;
#[AsCommand(name: 'auth:clear-resets')]
class ClearResetsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'auth:clear-resets {name? : The name of the password broker}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Flush expired password reset tokens';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->laravel['auth.password']->broker($this->argument('name'))->getRepository()->deleteExpired();
$this->components->info('Expired reset tokens cleared successfully.');
}
}