<?php

namespace App\Services;

use App\Models\TranslateTemplate;

class TranslateTemplatePublishEligibilityService
{
    public function isLanguageTemplatePublished(string $languageCode): bool
    {
        $code = strtolower(trim((string) $languageCode));
        if ($code === '' || $code === 'english') {
            $code = 'en';
        }
        if ($code === 'en') {
            return true;
        }

        return TranslateTemplate::query()
            ->where('language_code', $code)
            ->where('status', 'Published')
            ->whereNull('deleted_at')
            ->exists();
    }
}
