2022-11-18 01:09:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
use App\User;
|
2024-12-06 07:44:16 +00:00
|
|
|
use Illuminate\Contracts\Console\PromptsForMissingInput;
|
2022-11-18 01:09:16 +00:00
|
|
|
|
2024-12-06 07:44:16 +00:00
|
|
|
class UserVerifyEmail extends Command implements PromptsForMissingInput
|
2022-11-18 01:09:16 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'user:verifyemail {username}';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Verify user email address';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2024-12-06 07:44:16 +00:00
|
|
|
$username = $this->argument('username');
|
|
|
|
$user = User::whereUsername($username)->first();
|
2022-11-18 01:09:16 +00:00
|
|
|
|
|
|
|
if(!$user) {
|
|
|
|
$this->error('Username not found');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-12-06 07:44:16 +00:00
|
|
|
if($user->email_verified_at) {
|
|
|
|
$this->error('Email already verified ' . $user->email_verified_at->diffForHumans());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-11-18 01:09:16 +00:00
|
|
|
$user->email_verified_at = now();
|
|
|
|
$user->save();
|
|
|
|
$this->info('Successfully verified email address for ' . $user->username);
|
|
|
|
}
|
|
|
|
}
|