Created
July 11, 2022 17:57
-
-
Save richardDobron/1a9235b5db64ff06718c2261c7e56c53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\Mail\Traits; | |
use Illuminate\Contracts\View\Factory as ViewFactory; | |
use Illuminate\Support\HtmlString; | |
use Soundasleep\Html2Text; | |
trait TextMailBuilder | |
{ | |
protected function buildView() | |
{ | |
if (isset($this->html)) { | |
if (! $this->textView) { | |
$plainText = Html2Text::convert($this->html); | |
$text = new HtmlString($plainText); | |
} else { | |
$text = $this->textView; | |
} | |
return array_filter([ | |
'html' => new HtmlString($this->html), | |
'text' => $text, | |
]); | |
} | |
if (isset($this->markdown)) { | |
return $this->buildMarkdownView(); | |
} | |
if (isset($this->view, $this->textView)) { | |
return [$this->view, $this->textView]; | |
} elseif (isset($this->textView)) { | |
return ['text' => $this->textView]; | |
} | |
return $this->view; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment