Is it possible to manually register a user (with artisan?) rather than via the auth registration page?
I only need a handful of user accounts and wondered if there's a way to create these without having to set up the registration controllers and views.
There is no need to make it this way. By default you have User model created and you should be able simple to create user this way: $user = new User(); $user->username = 'something'; $user->password = Hash::make('userpassword'); $user->email = '[email protected]'; $user->save();
I think you want to do this once-off, so there is no need for something fancy like creating an Artisan command etc. I would suggest to simply use php artisan tinker
(great tool!) and add the following commands per user:
$user = new App\User(); $user->password = Hash::make('the-password-of-choice'); $user->email = '[email protected]'; $user->name = 'My Name'; $user->save();
This is an old post, but if anyone wants to do it with command line, in Laravel 5.*, this is an easy way:
php artisan tinker
then type (replace with your data):
DB::table('users')->insert(['name'=>'MyUsername','email'=>'[email protected]','password'=>Hash::make('123456')])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With