data = $data; $this->user = $user; $this->sender = $sender; $this->subject = isset($data['subject']) ? $data['subject'] : __('email.email_subject'); $this->message = isset($data['message']) ? $data['message'] : ''; } public function build() { $salutation = __('email.salutation').","; if($this->user->account){ if($this->user->account->salutation === "mr"){ $salutation = __('email.dear_sir')." ".$this->user->account->first_name.","; }else{ $salutation = __('email.dear_mrs')." ".$this->user->account->first_name.","; } } UserMessage::create([ 'user_id' => $this->user->id, 'send_user_id' => $this->sender->id, 'email' => $this->user->email, 'subject' => $this->subject, 'message' => $this->message, 'send' => true, 'sent_at' => now(), ]); $url = ""; $button = ""; if(isset($this->data['confirmation_code'])){ $url = route('register_verify', $this->data['confirmation_code']); $button = __('email.button_account'); } return $this->view('emails.auth')->with([ 'url' => $url, 'salutation' => $salutation, 'button' => $button, 'copy1line' => $this->message, 'copy2line' => __('email.copy2line'), 'copy3line' => __('email.copy3line'), 'greetings' => __('email.greetings'), 'sender' => __('email.sender'), ]); } }