mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
init
This commit is contained in:
26
app/Console/Commands/CreateUserCommand.php
Normal file
26
app/Console/Commands/CreateUserCommand.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateUserCommand extends Command
|
||||
{
|
||||
protected $signature = 'user:create {name} {email}';
|
||||
|
||||
protected $description = 'Create a new user';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$password = Str::random(20);
|
||||
User::create([
|
||||
'name' => $this->argument('name'),
|
||||
'email' => $this->argument('email'),
|
||||
'password' => bcrypt($password),
|
||||
]);
|
||||
|
||||
$this->info("User created with password: {$password}");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user