replies()->create([ 'user_id' => $by->id, 'user_name' => $by->name, 'subject' => $subject, 'body' => $body, 'channel' => $send ? ApplicationReply::MAIL : ApplicationReply::MAILTO, ]); if ($send) { Mail::to($application->email, $application->name)->send(new ApplicationReplyMail($reply)); } // Answered is at least contacted; a decision already taken stays. if ($application->status === ApplicationStatus::New) { $application->markAs(ApplicationStatus::Contacted, $by); } return $reply; } /** * The same answer, for the person's own mail program to send. */ public static function mailto(Application $application, string $subject, string $body): string { return 'mailto:'.$application->email.'?subject='.rawurlencode($subject).'&body='.rawurlencode($body); } }