Init
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Command;
|
||||
|
||||
use Lunar\Admin\Console\Commands\MakeLunarAdminCommand;
|
||||
|
||||
use function Laravel\Prompts\text;
|
||||
|
||||
class CreateAdminCommand extends MakeLunarAdminCommand
|
||||
{
|
||||
protected $signature = 'lunar:create-admin
|
||||
{--firstname= : The first name of the user}
|
||||
{--lastname= : The last name of the user}
|
||||
{--email= : A valid and unique email address}';
|
||||
|
||||
protected function getUserData(): array
|
||||
{
|
||||
return [
|
||||
'first_name' => $this->options['firstname'] ?? text(
|
||||
label: 'First Name',
|
||||
required: true,
|
||||
),
|
||||
|
||||
'last_name' => $this->options['lastname'] ?? text(
|
||||
label: 'Last Name',
|
||||
required: true,
|
||||
),
|
||||
|
||||
'email' => $this->options['email'] ?? text(
|
||||
label: 'Email address',
|
||||
required: true,
|
||||
validate: fn (string $email): ?string => match (true) {
|
||||
! filter_var($email, FILTER_VALIDATE_EMAIL) => 'The email address must be valid.',
|
||||
\Lunar\Admin\Models\Staff::where('email', $email)->exists() => 'A user with this email address already exists',
|
||||
default => null,
|
||||
},
|
||||
),
|
||||
|
||||
'admin' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user