How do I manually send a password reset request in Laravel 5.2?
Thanks to Mariusz Kurman, I only added token to his answer. this works just fine:
$user = User::where('email', request()->input('email'))->first();
$token = Password::getRepository()->create($user);
$user->sendPasswordResetNotification($token);
Why not just something like this for your controller:
<?php
namespace Illuminate\Foundation\Auth;
use Illuminate\Http\Request;
use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Password;
class YourController extends Controller
{
public function sendEmail()
{
$credentials = ['email' => $email_address];
$response = Password::sendResetLink($credentials, function (Message $message) {
$message->subject($this->getEmailSubject());
});
switch ($response) {
case Password::RESET_LINK_SENT:
return redirect()->back()->with('status', trans($response));
case Password::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}
}
You don't really explain the context of how you want to send this, so adjust accordingly.