Я работаю с Laravel в качестве моего бэкэнда для моего проекта Vue и поэтому должен был изменить код подтверждения по электронной почте. Я сейчас сталкиваюсь с ошибкой при повторной отправке письма.
Ошибка: "Access to undeclared static property: App\Notifications\VerifyEmail::$toMailCallback"
Если я удалю if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable);
}
Он отправляет электронное письмо, но я получаю сообщение об ошибке с указанным кодом.
namespace App\Notifications;
...
class VerifyEmail extends Notification
{
use Queueable;
...
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable);
}
return (new MailMessage)
->subject('Verify Email Address')
->line('Please click the button below to verify your email address.')
->action(
'Verify Email Address',
$this->verificationUrl($notifiable)
)
->line('If you did not create an account, no further action is required.');
}
/**
* Get the verification URL for the given notifiable.
*
* @param mixed $notifiable
* @return string
*/
protected function verificationUrl($notifiable)
{
$prefix = config('app.front_url') . config('app.email_verify_url');
$temporarySignedURL = URL::temporarySignedRoute(
'verification.verify', Carbon::now()->addMinutes(60), ['id' => $notifiable->getKey()]
);
// I use urlencode to pass a link to my frontend.
return $prefix . urlencode($temporarySignedURL);
}
/**
* Set a callback that should be used when building the notification mail message.
*
* @param \Closure $callback
* @return void
*/
public static function toMailUsing($callback)
{
static::$toMailCallback = $callback;
}
...
}