feat: 테넌트 코드 생성 헬퍼 추가 및 RegisterService 적용

- TenantCodeGenerator 헬퍼 클래스 생성
  - 한글 초성 추출 및 영문 변환
  - Base-36 순번 생성 (최대 1,679,616 코드)
  - 순환형 코드 생성 (초성+순번 조합)
- RegisterService에서 테넌트 생성 시 코드 자동 생성
- 회원가입 시 'code' 필드 누락 오류 해결
This commit is contained in:
2025-11-07 18:11:03 +09:00
parent 8c2d2b4c14
commit be746041fc
2 changed files with 120 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Services;
use App\Helpers\TenantCodeGenerator;
use App\Models\Commons\Menu;
use App\Models\Members\User;
use App\Models\Tenants\Tenant;
@@ -35,9 +36,13 @@ class RegisterService
public static function register(array $params): array
{
return DB::transaction(function () use ($params) {
// 1. Create Tenant with trial status and options
// 1. Generate unique tenant code from company name
$code = TenantCodeGenerator::generate($params['company_name']);
// 2. Create Tenant with trial status and options
$tenant = Tenant::create([
'company_name' => $params['company_name'],
'code' => $code,
'business_num' => $params['business_num'] ?? null,
'tenant_st_code' => 'trial', // 트라이얼 상태
'options' => [