samedi 23 juillet 2016

$request is uninitialized in AuthenticatesUsers.php Laravel5

I want to send a notification email each time logging in successfully(just for testing since I'm out of email for registration to test sending email). I modify the handleUserWasAuthenticated function which I assume that this function will be called when logging in successfully. However, I cannot take email and username from the form's data through $request variable. The $request is also used in other places in handleUserWasAuthenticated function by default and there's no warning for these cases while only in my added codes, $request get warning "Variable $request seems to be uninitialized". How can I take the email and username for sending email?

This is the handleUserWasUathenticated function in AuthenticatesUser.php

protected function handleUserWasAuthenticated(Request $request, $throttles)
{
    //My modification
    $data = [
        'title' => 'Welcome to Myfirstsite',
        'content' => 'You have finished your registration successfully'
    ];

    Mail::send('emails.verification', $data, function($message){

        $message
            ->to($request['email'],$request['name'])
            ->subject('Verification email from Myfirstsite');

    });

    //Original part
    if ($throttles) {
        $this->clearLoginAttempts($request);
    }

    if (method_exists($this, 'authenticated')) {
        return $this->authenticated($request, Auth::guard($this->getGuard())->user());
    }

    return redirect()->intended($this->redirectPath());
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2agFHu0
via IFTTT

Aucun commentaire:

Enregistrer un commentaire