Skip to content

Instantly share code, notes, and snippets.

@emmadesilva
Last active January 15, 2024 11:00
Show Gist options
  • Select an option

  • Save emmadesilva/9ba0dcb25c7f9b083e20d69c628672cf to your computer and use it in GitHub Desktop.

Select an option

Save emmadesilva/9ba0dcb25c7f9b083e20d69c628672cf to your computer and use it in GitHub Desktop.
A simple Laravel `make:user` command
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
class MakeUserCommand extends Command
{
protected $signature = 'make:user';
protected $description = 'Create a new user';
public function handle(): void
{
$name = $this->ask('What is your name?');
$email = $this->ask('What is your email?');
$password = $this->secret('What is your password?');
$user = User::create([
'name' => $name,
'email' => $email,
'password' => bcrypt($password),
'email_verified_at' => now(),
]);
$this->info('User created successfully.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment