How to change User Password via Laravel Tinker command

Laravel tinker

Yesterday, my client asked me how to change his user password to login into the Admin Dashboard.

The Admin Dashboard itself was built with PHP Laravel. And the previous web developer didn’t build Change Password feature via Admin Dashboard.

Since that is not my current scope of work and not my responsibility to build Change Password Feature (although it was a simple task), I decide to help my clients to change his user password via Terminal with built in Laravel powerful REPL called Tinker!

Where is the change password field?

So without further ado, I asked for an SSH access to their server.

Here’s what I do to change my client user password via Terminal:

  1. Accessing server via SSH command on terminal
  2. Go to the web folder. Typically /var/www/appfoldername
  3. Within that folder, run the powerful Laravel Tinker command: php artisan tinker
  4. Do the magic!
php artisan tinker

You will now entering the Laravel console. All command will interpreted as PHP code. After that, type this following command:

$user = App\User::where('email', '')->first();

The command above will search a user with appropiate email that we are looking for (eg: put any email that you need to change password.

In my case, here’s the result:

found the user

Next, type the following command to change user password with the new desire password (eg: new_password):

$user->password = Hash::make('new_password');

To save the newly created password, type this following command:


Voila! My client user password have already changed with the new password that he wants.

Probably this is a very simple tip, but it is useful when you want to change user password via terminal with the powerful Laravel Tinker command.

Email icon representing an email newsletter

Don't subscribe