1. Go to this page and download the library: Download yaquawa/laravel-email-reset library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Models;
use Yaquawa\Laravel\EmailReset\CanResetEmail;
class User extends Authenticatable
{
use CanResetEmail;
}
// By calling the `resetEmail` method of `User` instance,
// an verification email will be sent to the user's new email address.
// If the user clicked the verification link, the new email address will be set.
// * The route of the verification link can be set at `route` in the config file.
$user->resetEmail('[email protected]');
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Notifications\Messages\MailMessage;
use Yaquawa\Laravel\EmailReset\Notifications\EmailResetNotification;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
EmailResetNotification::toMailUsing(function ($user, $token, $resetLink) {
return (new MailMessage)
->line('You are receiving this email because we received a email reset request for your account.')
->action('Reset Email', $resetLink)
->line('If you did not request a email reset, no further action is
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Yaquawa\Laravel\EmailReset\ResetEmail;
class ResetEmailController extends Controller
{
use ResetEmail;
/**
* This method will be called if the token is invalid.
* Should return a response that representing the token is invalid.
*
* @param $status
*
* @return mixed
*/
protected function sendResetFailedResponse(string $status)
{
return redirect($this->redirectPathForFailure())->withErrors(['laravel-email-reset' => trans($status)]);
}
/**
* This method will be called if the token is valid.
* New email will be set for the user.
* Should return a response that representing the email reset has succeeded.
*
* @param $status
*
* @return mixed
*/
protected function sendResetResponse(string $status)
{
return redirect($this->redirectPathForSuccess())->with('laravel-email-reset', trans($status));
}
/**
* The redirect path for failure.
*
* @return string
*/
protected function redirectPathForFailure(): string
{
return '/';
}
/**
* The redirect path for success.
*
* @return string
*/
protected function redirectPathForSuccess(): string
{
return '/';
}
}
$user->new_email; // retrieve the `new_email` from database
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.