ERROR: Declaration of App\Services\CustomPasswordBroker

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Error:

Declaration of App\Services\CustomPasswordBroker::sendResetLink(array $credentials, ?Illuminate\Http\Request $request = null) must be compatible with Illuminate\Auth\Passwords\PasswordBroker::sendResetLink(array $credentials, ?Closure $callback = null) {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Declaration of App\\Services\\CustomPasswordBroker::sendResetLink(array $credentials, ?Illuminate\\Http\\Request $request = null) must be compatible with Illuminate\\Auth\\Passwords\\PasswordBroker::sendResetLink(array $credentials, ?Closure $callback = null) at /opt/lampp/htdocs/devopsschool/ds-student-ms/app/Services/CustomPasswordBroker.php:18)
[stacktrace]
#0 {main}

Solution:

Step – 1 – Go to your Laravel 10 project.

Step – 2 – find the file named CustomPasswordBroker.php which is usually present in the \app\Services\CustomPasswordBroker.php.

Step – 3 – The Illuminate\Auth\Passwords\ basic classThe sendResetLink method in PasswordBroker has the following signature:

Replace your code from this:

public function sendResetLink(array $credentials, Request $request = NULL)
to this Code:

public function sendResetLink(array $credentials, $callback = NULL)

Step – 4 – And Replace the $request code from $callback in your whole file.

Step – 5 – As you can see my whole updated code below:

use Illuminate\Auth\Passwords\PasswordBroker as BasePasswordBroker;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\Request;

class CustomPasswordBroker extends BasePasswordBroker    
{    
@@ -15,12 +14,12 @@ class CustomPasswordBroker extends BasePasswordBroker
     * @param  array  $credentials
     * @return string
     */
    public function sendResetLink(array $credentials, Request $request = NULL)
    public function sendResetLink(array $credentials, $callback = NULL)
    {
    	Log::info('--- Inside CustomPasswordBroker->sendResetLink() ---');
    	$case = '';
    	if($request !== NULL && $request->get('case') != "") {
    		$case = $request->get('case');
    	if($callback !== NULL && $callback->get('case') != "") {
    		$case = $callback->get('case');
    	}

        Log::info('--- Inside CustomPasswordBroker->sendResetLink() ---');
        
        $user = $this->getUser($credentials);
        if (is_null($user)) {
            return static::INVALID_USER;
        }
       
        Log::info('$case: ' . $case);
        switch ($case) {
    		case 'new-user-first-quote':
    			$user->sendAccountActivationNotification(
		            $this->tokens->create($user), 'activate', $user->email
		        );
    			break;

Senior Software Development Engineer at Cotocus

Related Posts

How We Fixed a Stubborn Laravel MeiliSearch Bulk Indexing Failure (16,000+ Records)

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now If…

Read More

Laravel Search Without Docker, Queues, or Horizon

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now Modern…

Read More

Laravel Scout with Typesense vs Meilisearch

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now Modern…

Read More

SESSION_DRIVER=file vs SESSION_DRIVER=database in Laravel

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now Which…

Read More

Laravel Logging: Complete Step-by-Step Guide to Enable, Debug, Verify, and Master Logs in Any Laravel Project

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now Logging…

Read More

Complete Tutorial: Setting Up Laravel Telescope Correctly (Windows + XAMPP + Custom Domain)

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now This…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments