mirror of
https://github.com/alexjustesen/speedtest-tracker.git
synced 2026-06-23 07:10:10 +00:00
ce21ae24db
Co-authored-by: Shift <shift@laravelshift.com>
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class ResetUserPassword extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'app:reset-user-password
|
|
{email : The email address of the user}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Reset the password for a user\'s account.';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
$user = User::firstWhere('email', $this->argument('email'));
|
|
|
|
if (! $user) {
|
|
// couldn't find the user so should fail.
|
|
$this->error('Could not find a user with the email address of '.$$this->argument('email'));
|
|
|
|
return;
|
|
}
|
|
|
|
$password = $this->secret('What is the password?');
|
|
|
|
$user->update([
|
|
'password' => Hash::make($password),
|
|
]);
|
|
}
|
|
}
|