Need to make users from the Artisan console? Add this command!
1nano app/Console/Commands/MakeUserCommand.php
1<?php 2 3namespace App\Console\Commands; 4 5use App\Models\User; 6use Illuminate\Console\Command; 7 8class MakeUserCommand extends Command 9{10 protected $signature = 'make:user';11 protected $description = 'Create a new user';12 13 public function handle(): void14 {15 $name = $this->ask('What is your name?');16 $email = $this->ask('What is your email?');17 $password = $this->secret('What is your password?');18 19 $user = User::create([20 'name' => $name,21 'email' => $email,22 'password' => bcrypt($password),23 'email_verified_at' => now(),24 ]);25 26 $this->info("User #$user->id created successfully.");27 }28}
1php artisan make:user
Syntax highlighting by Torchlight.dev