Last active
January 15, 2024 11:00
-
-
Save emmadesilva/9ba0dcb25c7f9b083e20d69c628672cf to your computer and use it in GitHub Desktop.
A simple Laravel `make:user` command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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