Given the route:
Route::get('verify/{id}/{hash}', 'Auth\VerificationController@verify'); It uses the Laravel's default verify method from
auth-backend/VerifiesEmails.php The default verify method looks like bellow:
public function verify(Request $request) { if (! hash_equals((string) $request->route('id'), (string) $request->user()->getKey())) { throw new AuthorizationException; } if (! hash_equals((string) $request->route('hash'), sha1($request->user()->getEmailForVerification()))) { throw new AuthorizationException; } if ($request->user()->hasVerifiedEmail()) { return $request->wantsJson() ? new Response('', 204) : redirect($this->redirectPath()); } if ($request->user()->markEmailAsVerified()) { event(new Verified($request->user())); } if ($response = $this->verified($request)) { return $response; } return $request->wantsJson() ? new Response('', 204) : redirect($this->redirectPath())->with('verified', true); } I would like to change only the last block of the code in the verify method from
return $request->wantsJson() ? new Response('', 204) : redirect($this->redirectPath())->with('verified', true); to
return $request->wantsJson() ? new Response('', 204) : redirect($this->redirectPath())->with([ 'verified' => true, 'userNotification' => [ 'message' => 'Wellcome to my website', 'title' => 'Hello World', ], ]); I know I can override the whole verify method in the VerificationController, which is not ideal to copy and paste the whole block of code for a small change. My question is How can override only the last block of code as mentioned above?