content = $body; $this->cv_file = $cv_file; } public function build() { $subject = __('A candidate apply for your job'); if(!empty($this->cv_file->file_path) && file_exists(public_path().'/uploads/'.$this->cv_file->file_path)){ return $this->subject($subject) ->view('jobportaljob::emails.apply-job',['content' => $this->content]) ->attach( public_path().'/uploads/'. $this->cv_file->file_path, [ 'as' => $this->cv_file->file_name.'.'.$this->cv_file->file_extension, 'mime' => $this->cv_file->file_type, ]); }else{ return $this->subject($subject)->view('jobportaljob::emails.apply-job',['content' => $this->content]); } } }