Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29898

Laravel - Trying to get property 'view' of non-object, when sending mail

$
0
0

I'm trying to send a validation email to a registering customers email address, but It is giving me the error in question rather than sending the notification email.

Create user :

$validator = Validator::make($request->all(), [
    'name'     => ['required', 'alpha_dash', 'string', 'max:25', 'unique:customers'],
    'email'    => ['required', 'string', 'email', 'max:255', 'unique:customers'],
    'password' => ['required', 'string', 'min:6', 'confirmed'],
]);

if ( $validator->fails() ) {
    $messages = $validator->messages();
    return Redirect::back()->withErrors($validator)->withInput();
    foreach($errors->all() as $error) {
        echo $error;
    }
} elseif ( $validator->passes() ) {
    $customer = customer::create([
        'name' => $request['name'],
        'email' => $request['email'],
        'password' => Hash::make($request['password']),
        'VerifyToken' => Str::random(40),
    ]);

    $customer->SendEmailVerificationNotification();

    return redirect()->intended('login/customer');
}

SendEmailVerificationNotifaction:

public function toMail($notifiable)
{
    $verificationUrl = $this->verificationUrl($notifiable);

    if (static::$toMailCallback) {
        return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl);
    }

    Mail::to($notifiable->email)->send(new validate_email($notifiable->email));
}

Any help would be fantastic! Struggling here Thankyou :)


Viewing all articles
Browse latest Browse all 29898

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>