Last active
March 5, 2024 02:20
-
-
Save meigwilym/d8ac0b724b4ef9c20ed7768c92838d92 to your computer and use it in GitHub Desktop.
Laravel Create 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 | |
// routes/console.php | |
// quickly create an user via the command line | |
Artisan::command('user:create', function () { | |
$name = $this->ask('Name?'); | |
$email = $this->ask('Email?'); | |
$pwd = $this->ask('Password?'); | |
// $pwd = $this->secret('Password?'); // or use secret() to hide the password being inputted | |
\DB::table('users')->insert([ | |
'name' => $name, | |
'email' => $email, | |
'password' => bcrypt($pwd), | |
'created_at' => date_create()->format('Y-m-d H:i:s'), | |
'updated_at' => date_create()->format('Y-m-d H:i:s'), | |
]); | |
$this->info('Account created for '.$name); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to use
laravel/prompts