ResetPassword.php questions

Published 5 months ago by SomeT

For the file located at: \vendor\laravel\framework\src\Illuminate\Auth\Notifications\ResetPassword.php I believe this allows me to edit the default email sent for resetting password however I have two questions before I edit it.

  • If I update this locally will it cause any issues on my live deployment? I usually have vendor folder in my gitignore for deployment thus usual updates around this where I don't normally edit php files, are done within composer.lock and composer.json

  • Even if I did edit this file there are still two parts of the default email I want to change, the wording of Laravel at the top of the email and: 'Regards, Laravel' at the bottom, how would I even edit these because I can't see how in ResetPassword.php?

Best Answer (As Selected By SomeT)
tykus

It is not a good idea to edit anything in the vendor directory.

Instead, you can override the sendPasswordResetNotification method on the User model, and specify the Mailable you wish to send.

The Laravel header and signature are both based off of the APP_NAME environment variable which you can set in the .env file.

Cronix
Cronix
5 months ago (783,420 XP)

No! Don't ever edit anything in /vendor. Your changes will get overwritten with composer updates.

php artisan vendor:publish

If you have a very recent version of laravel, it will give you a menu of assets to publish. Look for one mentioning laravel mail and possibly laravel notifications. It will copy them to /resources/views/vendor where you can edit them safely and they will be included in your repo leaving /vendor pure. Laravel will look there first for views before using the ones in /vendor.

If it's an earlier version of laravel, it will publish everything available unless you specify which package to publish.

Edit: for your other questions, after you publish the assets, you will find a layout.blade.php for the emails. That's the master template and it includes a header and footer view (among others). You can edit those how you like.

jlrdw
jlrdw
5 months ago (251,870 XP)

Do not modify files under vendor there's an artisian commant to make Auth. It is setup to use a trait to change or put in what's needed.

You may want to re-read docs on it and perhaps view a video or two on authentication.

tykus
tykus
5 months ago (690,060 XP)

It is not a good idea to edit anything in the vendor directory.

Instead, you can override the sendPasswordResetNotification method on the User model, and specify the Mailable you wish to send.

The Laravel header and signature are both based off of the APP_NAME environment variable which you can set in the .env file.

SomeT

I forgot to mention I have done php artisan make:auth I am not sure if that makes a difference to your answer @Cronix ? From what you have indicated I need to do php artisan vendor:publish on top of the already done php artisan make:auth to create new templated files for my email reset templates in order for me to edit them outside vendor? Correct? This is what my views currently look like: https://gyazo.com/37d0d0d744e9177fe524b4d35dccbe50

tykus
tykus
5 months ago (690,060 XP)

@Somet the views you show are not the email templates. See my answer above.

Cronix
Cronix
5 months ago (783,420 XP)

Yes, make:auth only publishes the actual views/routes for auth. It doesn't publish the email or notification views.

After you publish them, you'll find them in /resources/views/vendor/mail/html and a few others

SomeT

It sounds like the easiest thing for me to do here, especially as a beginner still learning is edit the .env file.

Cronix
Cronix
5 months ago (783,420 XP)

If you use markdown/html mail, it will still use the header and footer from the assets that weren't published, unless you override them.

SomeT

Many thanks for the answers, I think for now changing app name in .env is enough as I am still learning but I keep these questions stored for my future reference.

Please sign in or create an account to participate in this conversation.