Does anyone know how to override the functions used within laravel's password broker? I know the docs:
https://laravel.com/docs/5.3/passwords#resetting-views
Give information on what to do for things like views and a few surface level things but it's not clear at all really or maybe I'm not reading it enough times.
I already know how to override the ResetsPasswords.php
Trait but overriding the functionality of the Password::broker()
is for the next layer in.
If there is more information needed I can kindly provide some.
Thank you in advance.
There are some missing things for step 1 & 3 in the answer https://stackoverflow.com/a/42855948/2311074
Step 1
Probably the safest way is to simply copy the class from
Illuminate\Auth\Passwords\PassswordResetServiceProvider.php
toApp\Provider\CustomPasswordResetServiceProvider
and change:namespace App\Providers;
CustomPasswordResetServiceProvider
use App\Services\CustomPasswordBrokerManager;
to the topregisterPasswordBroker
renamePasswordBrokerManager
toCustomPasswordBrokerManager
Step 2.
Besides changing the resolve method also do the following:
namespace App\Services;
use Illuminate\Auth\Passwords\DatabaseTokenRepository;
to the topCustomPasswordBrokerManager
I had to face the same issue, needed to override some of the PasswordBroker functions. After a lot of investigation on the web and many failed attempts to do so, I ended up to the following implementation:
Created a CustomPasswordResetServiceProvider inside App\Providers where I registered a CustomPasswordBrokerManager instance.
In config/app.php commented out line:
//Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
and added:
App\Providers\CustomPasswordResetServiceProvider::class,
Inside App\Services folder created a CustomPasswordBrokerManager and copied the context of the default PasswordBrokerManager located at:
Illuminate\Auth\Passwords\PasswordBrokerManager.php
Then modified the function resolve to return an instance of my CustomPasswordProvider class.
Finally inside App\Services folder I created a CustomPasswordBroker class which extends default PasswordBroker located at:
Illuminate\Auth\Passwords\PasswordBroker and overridden the functions that I needed.
Not sure if this is the best implementation but it worked for me.