<?php

namespace App\Mail;

use App\Facades\Settings;

trait CheckThemeTemplateTrait
{
    private function getTemplateName(string $template): string
    {
        $theme = Settings::get('mail-customer-theme');
        if (empty($theme) || $theme === 'default') {
            return 'crm::emails.' . $template;
        }

        if (view()->exists("crm::emails.$theme.$template")) {
            return "crm::emails.$theme.$template";
        }

        return 'crm::emails.' . $template;
    }
}
