'boolean', ]; public static function getTemplate(string $name): ?self { return static::where('name', $name) ->where('is_active', true) ->first(); } public static function render(string $name, array $variables): ?array { $template = static::getTemplate($name); if (! $template) { return null; } $subject = $template->subject; $body = $template->body; foreach ($variables as $key => $value) { $subject = str_replace('{{' . $key . '}}', $value, $subject); $body = str_replace('{{' . $key . '}}', $value, $body); } return [ 'subject' => $subject, 'body' => $body, ]; } }