public static function send(User $user) { if (!$user->confirmation) { $confirmation = new Confirmation(['content' => ConfirmationMailer::randomString()]); $user->confirmation()->save($confirmation); } else { $confirmation = $user->confirmation; $confirmation->content = ConfirmationMailer::randomString(); $confirmation->save(); } $data = ['email' => $user->email, 'confirmation_link' => url('confirmate/' . $confirmation->content), 'url' => url()]; Mail::send('emails.confirmation', $data, function ($message) use($user) { $message->to($user->email)->subject('Подтверждение регистрации на сайте rate-and-go.com'); }); }
public function sendConfirmationMail() { $user = $this->user->find(Session::get('id')); ConfirmationMailer::send($user); return '{"success":"Письмо отправлено"}'; }