23 lines
649 B
PHP
23 lines
649 B
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
|
|
Artisan::command('tarnax:admin {email}', function () {
|
|
$user = User::where('email', $this->argument('email'))->first();
|
|
if (! $user) {
|
|
$this->error('Register and verify this account first.');
|
|
|
|
return 1;
|
|
}
|
|
if (! $user->hasVerifiedEmail()) {
|
|
$this->error('Verify the email address first.');
|
|
|
|
return 1;
|
|
}
|
|
$user->forceFill(['is_admin' => true])->save();
|
|
$this->info('Administrator granted. Confirm 2FA in account security before opening /admin.');
|
|
|
|
return 0;
|
|
})->purpose('Promote a verified customer to administrator');
|