-
-
Save gnovaro/6d787405ccae9ef2bc0ffae949baad41 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