Manually register a user in Laravel

Matt Ellis picture Matt Ellis · Mar 2, 2016 · Viewed 74.3k times · Source

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.

Answer

Christoffer Tyrefors picture Christoffer Tyrefors · Mar 2, 2016

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();