cleanse's avatar

Laravel 5 Password Reset Subject

/**
 * Send the password reminder e-mail.
 *
 * @param  \Illuminate\Auth\Reminders\RemindableInterface  $user
 * @param  string    $token
 * @param  \Closure  $callback
 * @return int
 */
public function sendReminder(RemindableInterface $user, $token, Closure $callback = null)
{
    // We will use the reminder view that was given to the broker to display the
    // password reminder e-mail. We'll pass a "token" variable into the views
    // so that it may be displayed for an user to click for password reset.
    $view = $this->reminderView;
    return $this->mailer->send($view, compact('token', 'user'), function($m) use ($user, $token, $callback)
    {
        $m->to($user->getReminderEmail());
        if ( ! is_null($callback)) call_user_func($callback, $m, $user, $token);
    });
}

How could we pass this interface a subject without modifying the framework?

Controller:

public function postEmail(Request $request)
{
    switch ($response = $this->passwords->sendResetLink($request->only('email')))
    {
        case PasswordBroker::INVALID_USER:
            return redirect()->back()->withErrors(['email' =>trans($response)]);

        case PasswordBroker::RESET_LINK_SENT:
            return redirect()->back()->with('status', trans($response));
    }
}
0 likes
2 replies
bestmomo's avatar
Level 52
switch ($response = $this->passwords->sendResetLink($request->only('email'), function($message)
{
    $message->subject(...);
}))
{
        case PasswordBroker::INVALID_USER:
            return redirect()->back()->withErrors(['email' =>trans($response)]);

        case PasswordBroker::RESET_LINK_SENT:
            return redirect()->back()->with('status', trans($response));
}

Please or to participate in this conversation.