add controllers, servoices

This commit is contained in:
root
2026-03-09 02:52:13 -04:00
parent c8de5f7edc
commit d76c871cb7
501 changed files with 34439 additions and 21843 deletions
@@ -0,0 +1,45 @@
<?php
namespace App\Services\BroadcastEmail;
use Illuminate\Support\Facades\View;
class BroadcastEmailComposerService
{
public function sanitizeHtml(string $html): string
{
$html = preg_replace('#<(script|iframe)[^>]*>.*?</\\1>#is', '', $html);
$html = preg_replace('/\\son\\w+="[^"]*"/i', '', $html);
$html = preg_replace("/\\son\\w+='[^']*'/i", '', $html);
return $html ?? '';
}
public function compose(
bool $wrapLayout,
string $subject,
string $body,
string $recipientName,
string $preheader = '',
string $ctaText = '',
string $ctaUrl = '',
bool $personalize = true
): string {
$content = $personalize ? str_replace('{{name}}', $recipientName, $body) : $body;
if (!$wrapLayout) {
return $content;
}
if (!View::exists('emails.broadcast_wrapper')) {
return $content;
}
return view('emails.broadcast_wrapper', [
'subject' => $subject,
'content' => $content,
'preheader' => $preheader,
'cta_text' => $ctaText,
'cta_url' => $ctaUrl,
])->render();
}
}