How to update the user password in a Laravel project using the CLI

Laravel includes Tinker, a REPL tool to interact with the Eloquent ORM and a lot of other items. Using this tool, you can update the user password. To do this, open Tinker:

$ php artisan tinker
Psy Shell v0.7.2

Once you are in the interactive console, search for the user with the example@example.com email, update the password and persist the user in the database:

$user = App\User::where('email', 'example@example.com')->first();
$user->password = Hash::make('password');
$user->save();
exit();

And that’s all, folks.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.