Skip to content

Instantly share code, notes, and snippets.

@SalvadorP
Last active November 19, 2020 17:11
Show Gist options
  • Save SalvadorP/70b9ef73e048d0574482 to your computer and use it in GitHub Desktop.
Save SalvadorP/70b9ef73e048d0574482 to your computer and use it in GitHub Desktop.
Laravel 5.1 how to create a user using artisan tinker and the standard user model
php artisan tinker
$user = new App\User;
$user->name="Admin";
$user->email="admin@localhost.com";
$user->password=bcrypt('1234');
$user->save();
@aliabbasi68
Copy link

This is very Good :-)

@soaresdiogo
Copy link

But and the Role?

@mohamedhafezqo
Copy link

@soaresdiogo This is adding new User in a basic way, so you can add Role, ... also you can make it complicated as much as you can

@syabasri
Copy link

Thank!! Very helped me.

@SalvadorP
Copy link
Author

Thanks for the comments and the stars!
I'm happy that this helped someone :)

@agestaputrama
Copy link

can some one help. when "$user = new App/User;" i get this "Undefined index: App/User in C:/xampp/htdocs/laravel-vue/vendor/laravel/framework/src/Illu
minate/Database/Eloquent/Model.php "

but the data still save to the user table. can someone explain this?

@DiamondArt
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment