v7.0.0-beta.4 release
This commit is contained in:
1 parent
05db17887d
commit
1db039ff34
1545 files changed
+136783
-11634
No files matched your search
@@ -40,7 +40,9 @@ class MenuFactory extends Factory
|
||||
'parent_id' => null,
|
||||
'order' => $this->faker->numberBetween(1, 100),
|
||||
'is_active' => true,
|
||||
'module_id' => null,
|
||||
// menus 스키마는 module_id 를 extension_type/extension_identifier 로 이행
|
||||
'extension_type' => null,
|
||||
'extension_identifier' => null,
|
||||
'created_by' => User::factory(),
|
||||
];
|
||||
}
|
||||
@@ -58,10 +60,11 @@ class MenuFactory extends Factory
|
||||
/**
|
||||
* 모듈 메뉴 상태
|
||||
*/
|
||||
public function moduleMenu(int $moduleId = 1): static
|
||||
public function moduleMenu(string $moduleIdentifier = 'sirsoft-ecommerce'): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'module_id' => $moduleId,
|
||||
'extension_type' => 'module',
|
||||
'extension_identifier' => $moduleIdentifier,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -81,7 +84,8 @@ class MenuFactory extends Factory
|
||||
public function coreMenu(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'module_id' => null,
|
||||
'extension_type' => 'core',
|
||||
'extension_identifier' => 'core',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,9 @@ class TemplateLayoutVersionFactory extends Factory
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
// 모델 cast 가 'array' 로 지정되어 있으므로 JSON 인코딩은 Laravel 이 자동 수행한다.
|
||||
// Repository::buildChangesSummary 가 생성하는 스키마와 일치시킨다:
|
||||
// added/removed/modified = 배열(경로 문자열 목록), char_diff = 정수.
|
||||
return [
|
||||
'layout_id' => TemplateLayout::factory(),
|
||||
'version' => fake()->unique()->numberBetween(1, 1000),
|
||||
@@ -25,12 +28,12 @@ class TemplateLayoutVersionFactory extends Factory
|
||||
'layout_name' => fake()->word(),
|
||||
'components' => [],
|
||||
],
|
||||
'changes_summary' => json_encode([
|
||||
'added' => fake()->numberBetween(1, 20),
|
||||
'removed' => fake()->numberBetween(0, 10),
|
||||
'is_restored' => false,
|
||||
'restored_from' => null,
|
||||
]),
|
||||
'changes_summary' => [
|
||||
'added' => [],
|
||||
'removed' => [],
|
||||
'modified' => [],
|
||||
'char_diff' => fake()->numberBetween(-500, 500),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\UserStatus;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -23,6 +24,10 @@ class UserFactory extends Factory
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
// status: DB default 는 'active' 이지만 factory create 시 in-memory 인스턴스에는
|
||||
// default 가 반영되지 않아 `$user->status === null` 상태가 된다. 이 인스턴스를
|
||||
// actingAs() 로 세팅하면 CheckUserStatus 미들웨어가 null !== 'active' 로 판정해
|
||||
// 403 을 반환하므로, factory 단에서 명시 지정하여 production-like 완전 상태로 생성한다.
|
||||
return [
|
||||
'uuid' => Str::orderedUuid()->toString(),
|
||||
'name' => fake()->name(),
|
||||
@@ -31,6 +36,7 @@ class UserFactory extends Factory
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
'is_super' => false,
|
||||
'status' => UserStatus::Active->value,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* users 테이블에 본인인증(IdentityVerification) 관련 컬럼을 추가합니다.
|
||||
*
|
||||
* - identity_verified_at : 최종 성공 본인인증 시각
|
||||
* - identity_verified_provider : 감사용 프로바이더 식별자
|
||||
* - identity_verified_purpose_last : 최근 민감 작업 재인증 경과시간 UX
|
||||
* - identity_hash : 프로바이더 교체 시 동일인 매칭 (SHA256 정규화 식별자)
|
||||
* - mobile_verified_at : email_verified_at 과 대칭, SMS 프로바이더 대비
|
||||
*
|
||||
* @since 7.0.0-beta.4
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->timestamp('identity_verified_at')
|
||||
->nullable()
|
||||
->after('email_verified_at')
|
||||
->comment('최종 성공 본인인증 시각');
|
||||
|
||||
$table->string('identity_verified_provider', 64)
|
||||
->nullable()
|
||||
->after('identity_verified_at')
|
||||
->comment('최근 본인인증에 사용한 프로바이더 식별자');
|
||||
|
||||
$table->string('identity_verified_purpose_last', 32)
|
||||
->nullable()
|
||||
->after('identity_verified_provider')
|
||||
->comment('최근 본인인증 목적 (signup|password_reset|self_update|sensitive_action|...)');
|
||||
|
||||
$table->char('identity_hash', 64)
|
||||
->nullable()
|
||||
->after('identity_verified_purpose_last')
|
||||
->comment('프로바이더 교체 시 동일인 매칭용 정규화 식별자 (SHA256)');
|
||||
|
||||
$table->timestamp('mobile_verified_at')
|
||||
->nullable()
|
||||
->after('identity_hash')
|
||||
->comment('휴대전화 인증 시각 (email_verified_at 과 대칭)');
|
||||
|
||||
$table->index('identity_hash', 'idx_users_identity_hash');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_users_identity_hash');
|
||||
$table->dropColumn([
|
||||
'identity_verified_at',
|
||||
'identity_verified_provider',
|
||||
'identity_verified_purpose_last',
|
||||
'identity_hash',
|
||||
'mobile_verified_at',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* identity_verification_logs 테이블을 신설합니다.
|
||||
*
|
||||
* Challenge 생명주기(requested/sent/verified/failed/expired/cancelled/policy_violation_logged)
|
||||
* 감사 로그. activity_logs 는 사용자 관점 서사, 이 테이블은 challenge 기술 이벤트를 기록합니다.
|
||||
* 기본 보관주기 180일 (관리자가 logs.purge 권한으로 즉시 삭제 가능).
|
||||
*
|
||||
* @since 7.0.0-beta.4
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('identity_verification_logs', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary()->comment('Challenge UUID');
|
||||
$table->string('provider_id', 64)->index()->comment('프로바이더 식별자 (예: g7:core.mail, kcp)');
|
||||
$table->string('purpose', 32)->index()->comment('인증 목적 (signup|password_reset|self_update|sensitive_action|*module-defined*) — 코어 4종은 App\\Enums\\IdentityVerificationPurpose enum, 모듈/플러그인은 declaredPurposes 레지스트리');
|
||||
$table->string('channel', 16)->comment('인증 채널 (email|sms|ipin|...) — 코어 enum=App\\Enums\\IdentityVerificationChannel, 모듈/플러그인 provider 가 추가 채널 등록 가능');
|
||||
|
||||
$table->foreignId('user_id')
|
||||
->nullable()
|
||||
->index()
|
||||
->constrained('users')
|
||||
->nullOnDelete()
|
||||
->comment('사용자 탈퇴 시 NULL 로 유지 — 감사 이력 보존 (CASCADE 금지 규정 준수)');
|
||||
|
||||
$table->string('target_hash', 64)->index()->comment('SHA256(email|phone) — PII 원본 저장 회피');
|
||||
$table->string('status', 32)->index()->comment('인증 challenge 생명주기 상태 (requested|sent|processing|verified|failed|expired|cancelled|policy_violation_logged) — App\\Enums\\IdentityVerificationStatus enum');
|
||||
$table->string('render_hint', 32)->nullable()->comment('프론트 렌더 힌트 (text_code|link|external_redirect)');
|
||||
|
||||
$table->unsignedSmallInteger('attempts')->default(0)->comment('시도 횟수');
|
||||
$table->unsignedSmallInteger('max_attempts')->default(5)->comment('허용 최대 시도 횟수');
|
||||
|
||||
$table->ipAddress('ip_address')->nullable()->comment('요청 IP');
|
||||
$table->string('user_agent', 512)->nullable()->comment('요청 User-Agent');
|
||||
|
||||
// 인증 경로 — 이슈 #297 요구사항 8.3
|
||||
$table->string('origin_type', 20)
|
||||
->nullable()
|
||||
->index()
|
||||
->comment('인증 트리거 출처 유형 (route|hook|policy|middleware|api|custom|system) — App\\Enums\\IdentityOriginType enum');
|
||||
|
||||
$table->string('origin_identifier', 255)
|
||||
->nullable()
|
||||
->index()
|
||||
->comment('실제 경로/훅명/정책키 (예: PUT /api/me/password, core.user.before_update)');
|
||||
|
||||
$table->string('origin_policy_key', 120)
|
||||
->nullable()
|
||||
->index()
|
||||
->comment('정책이 트리거한 경우 identity_policies.key 참조');
|
||||
|
||||
$table->json('properties')->nullable()->comment('요청 페이로드 요약');
|
||||
$table->json('metadata')->nullable()->comment('프로바이더 내부 데이터 (코드 해시 등)');
|
||||
|
||||
$table->string('verification_token', 128)
|
||||
->nullable()
|
||||
->unique()
|
||||
->comment('Mode B verify 성공 시 발급되는 서명 토큰 (purpose+target_hash 바인딩)');
|
||||
|
||||
$table->timestamp('expires_at')->nullable()->index()->comment('Challenge 만료 시각');
|
||||
$table->timestamp('verified_at')->nullable()->comment('검증 완료 시각');
|
||||
$table->timestamp('consumed_at')->nullable()->comment('Mode B verification_token 이 register 에서 소비된 시각');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['provider_id', 'status', 'created_at'], 'idx_idv_logs_provider_status_created');
|
||||
$table->index(['origin_type', 'origin_identifier'], 'idx_idv_logs_origin');
|
||||
$table->index(['purpose', 'user_id', 'verified_at'], 'idx_idv_logs_purpose_user_verified');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('identity_verification_logs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* identity_policies 테이블을 신설합니다.
|
||||
*
|
||||
* 운영자/플러그인이 "어느 지점에 어떤 purpose 의 IDV 를 어떤 TTL 로 강제할지" 선언형으로 등록하는 저장소.
|
||||
* 알림 시스템의 notification_definitions 동형 패턴 — config/core.php.identity_policies 블록 +
|
||||
* IdentityPolicySyncHelper + {벤더}IdentityPolicySeeder 3단 구조로 동기화됩니다.
|
||||
*
|
||||
* @since 7.0.0-beta.4
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('identity_policies', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key', 120)->unique()->comment('정책 식별자 (예: core.profile.password_change)');
|
||||
$table->string('scope', 16)->index()->comment('정책 적용 범위 (route|hook|custom) — App\\Enums\\IdentityPolicyScope enum');
|
||||
$table->string('target', 255)->comment('라우트명/URI 패턴, 훅 이름, 또는 custom key');
|
||||
$table->string('purpose', 64)->comment('IDV 목적 (signup|password_reset|self_update|sensitive_action|*module-defined*) — 코어 4종은 App\\Enums\\IdentityVerificationPurpose enum');
|
||||
$table->string('provider_id', 64)->nullable()->comment('null 이면 purpose 기본 provider 사용');
|
||||
$table->unsignedInteger('grace_minutes')->default(0)->comment('최근 N 분 이내 동일 purpose verified 재사용 허용');
|
||||
$table->boolean('enabled')->default(true)->index()->comment('활성화 여부');
|
||||
$table->unsignedSmallInteger('priority')->default(100)->comment('매칭 우선순위 (DESC)');
|
||||
$table->json('conditions')->nullable()->comment('역할/HTTP 메서드/파라미터 매칭 조건 JSON');
|
||||
$table->string('source_type', 20)->default('core')->comment('정책 출처 (core|module|plugin|admin) — App\\Enums\\IdentityPolicySourceType enum');
|
||||
$table->string('source_identifier', 100)->default('core')->comment('출처 식별자 (예: sirsoft-ecommerce)');
|
||||
$table->string('applies_to', 16)->default('both')->comment('대상 사용자 스코프 (self|admin|both) — App\\Enums\\IdentityPolicyAppliesTo enum');
|
||||
$table->string('fail_mode', 16)->default('block')->comment('정책 실패 시 동작 (block=HTTP 428 / log_only=감사 로그만) — App\\Enums\\IdentityPolicyFailMode enum');
|
||||
$table->json('user_overrides')->nullable()->comment('운영자가 S1d UI 로 수정한 필드 목록 (Seeder 재실행 시 보존)');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['scope', 'target', 'enabled'], 'idx_idp_scope_target_enabled');
|
||||
$table->index(['source_type', 'source_identifier'], 'idx_idp_source');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('identity_policies');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 언어팩 테이블을 생성합니다.
|
||||
*
|
||||
* 슬롯(scope, target_identifier, locale) 단위로 여러 벤더의 언어팩이 공존할 수 있으며,
|
||||
* 슬롯당 active 상태는 1개만 허용됩니다 (functional unique index 로 강제).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('language_packs', function (Blueprint $table) {
|
||||
$table->id()->comment('언어팩 ID');
|
||||
$table->string('identifier', 200)->unique()->comment('언어팩 고유 식별자 ({vendor}-{scope}-{target?}-{locale})');
|
||||
$table->string('vendor', 100)->comment('언어팩 제작자 식별자');
|
||||
$table->enum('scope', ['core', 'module', 'plugin', 'template'])->comment('적용 대상 분류');
|
||||
$table->string('target_identifier', 150)->nullable()->comment('대상 확장 식별자 (scope=core일 때 null)');
|
||||
$table->string('locale', 20)->comment('IETF BCP-47 locale 태그');
|
||||
$table->string('locale_name', 100)->comment('영문 언어명');
|
||||
$table->string('locale_native_name', 100)->comment('원어 언어명');
|
||||
$table->enum('text_direction', ['ltr', 'rtl'])->default('ltr')->comment('텍스트 방향');
|
||||
$table->string('version', 50)->comment('언어팩 버전');
|
||||
$table->string('latest_version', 50)->nullable()->comment('최신 버전 (자동 업데이트 체크)');
|
||||
$table->string('target_version_constraint', 100)->nullable()->comment('대상 확장 버전 제약 (semver)');
|
||||
$table->boolean('target_version_mismatch')->default(false)->comment('대상 버전 불일치 경고 플래그');
|
||||
$table->string('license', 50)->nullable()->comment('라이선스');
|
||||
$table->json('description')->nullable()->comment('언어팩 설명 (다국어)');
|
||||
$table->enum('status', ['installed', 'active', 'inactive', 'updating', 'error'])
|
||||
->default('installed')->comment('언어팩 상태');
|
||||
$table->boolean('is_protected')->default(false)->comment('제거 보호 플래그 (번들 팩)');
|
||||
$table->json('manifest')->comment('language-pack.json 전체 스냅샷');
|
||||
$table->string('source_type', 30)->nullable()->comment('설치 소스 유형 (zip/github/url/bundled/bundled_with_extension)');
|
||||
$table->string('source_url', 500)->nullable()->comment('설치 소스 URL 또는 경로');
|
||||
$table->foreignId('installed_by')->nullable()->constrained('users')->nullOnDelete()->comment('설치자 사용자 ID');
|
||||
$table->timestamp('installed_at')->nullable()->comment('설치 시각');
|
||||
$table->timestamp('activated_at')->nullable()->comment('활성화 시각');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['scope', 'target_identifier', 'locale'], 'language_packs_slot_index');
|
||||
$table->index('status', 'language_packs_status_index');
|
||||
$table->index('vendor', 'language_packs_vendor_index');
|
||||
});
|
||||
|
||||
// 슬롯당 active 1개 제약은 LanguagePackService 의 activate/deactivate 트랜잭션에서 보장합니다
|
||||
// (DB functional unique index 는 MySQL 환경에 따라 schema 가시성 이슈가 발생할 수 있어
|
||||
// application-level 일관성 보장 방식을 채택).
|
||||
}
|
||||
|
||||
/**
|
||||
* 언어팩 테이블을 제거합니다.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasTable('language_packs')) {
|
||||
Schema::drop('language_packs');
|
||||
}
|
||||
}
|
||||
};
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* identity_verification_logs.status 컬럼에 'processing' 값을 추가 반영합니다.
|
||||
*
|
||||
* 컬럼 자체는 string(32) — 새 enum 값 'processing' 을 위한 스키마 변경은 불필요.
|
||||
* 단, 컬럼 comment 가 기존 7값만 나열하고 있으므로 운영자 / DBA 가 raw 스키마만 봐도
|
||||
* 신규 비동기(Stripe Identity / 토스인증 push 등) 흐름의 의미를 파악할 수 있도록 갱신합니다.
|
||||
*
|
||||
* 함께 들어가는 변경:
|
||||
* - 코어 신규 엔드포인트 GET /api/identity/challenges/{id} (상태 폴링)
|
||||
* - 코어 신규 엔드포인트 POST /api/identity/callback/{providerId} (외부 redirect 콜백 수신)
|
||||
*
|
||||
* @since engine-v1.46.0
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('identity_verification_logs')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 기존 인덱스를 유지하면서 column comment 만 갱신.
|
||||
// ->index() 호출을 함께 두면 ->change() 가 인덱스 재추가를 시도해 'Duplicate key name' 에러 발생.
|
||||
Schema::table('identity_verification_logs', function (Blueprint $table) {
|
||||
$table->string('status', 32)
|
||||
->comment('requested|sent|processing|verified|failed|expired|cancelled|policy_violation_logged')
|
||||
->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('identity_verification_logs')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('identity_verification_logs', function (Blueprint $table) {
|
||||
$table->string('status', 32)
|
||||
->comment('requested|sent|verified|failed|expired|cancelled|policy_violation_logged')
|
||||
->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 본인인증 메시지 정의 테이블 생성.
|
||||
*
|
||||
* 알림 시스템(notification_definitions)과 분리된 IDV 전용 메시지 템플릿 시스템.
|
||||
* (provider_id, scope_type, scope_value) 매트릭스를 1차 키로 갖는다.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('identity_message_definitions', function (Blueprint $table) {
|
||||
$table->id()->comment('ID');
|
||||
$table->string('provider_id', 64)->comment('IDV 프로바이더 ID (예: g7:core.mail, kcp, portone)');
|
||||
$table->string('scope_type', 32)
|
||||
->comment('메시지 정의 스코프 (provider_default|purpose|policy) — App\\Enums\\IdentityMessageScopeType enum');
|
||||
$table->string('scope_value', 120)->default('')
|
||||
->comment('범위 값: provider_default 빈 문자열 / purpose 키 / policy 키');
|
||||
$table->text('name')->comment('다국어 표시명 ({"ko":"...", "en":"..."})');
|
||||
$table->mediumText('description')->nullable()->comment('다국어 설명');
|
||||
$table->text('channels')->comment('활성 채널 (현재 ["mail"], 향후 sms 등 확장)');
|
||||
$table->text('variables')->nullable()
|
||||
->comment('사용 가능 변수 메타데이터 ([{key, description}])');
|
||||
$table->string('extension_type', 20)->comment('확장 타입: core, module, plugin');
|
||||
$table->string('extension_identifier', 100)->comment('확장 식별자');
|
||||
$table->boolean('is_active')->default(true)->comment('활성 여부');
|
||||
$table->boolean('is_default')->default(true)->comment('시더 생성 여부');
|
||||
$table->text('user_overrides')->nullable()
|
||||
->comment('운영자가 수정한 필드명 목록 (예: ["name","is_active"])');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(
|
||||
['provider_id', 'scope_type', 'scope_value'],
|
||||
'idx_identity_message_def_provider_scope_unique'
|
||||
);
|
||||
$table->index(['provider_id', 'scope_type'], 'idx_identity_message_def_provider_scope');
|
||||
$table->index(['extension_type', 'extension_identifier'], 'idx_identity_message_def_extension');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 본인인증 메시지 정의 테이블 삭제.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('identity_message_definitions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 본인인증 메시지 템플릿 테이블 생성.
|
||||
*
|
||||
* 정의(identity_message_definitions) 1건 × 채널 N개 구조.
|
||||
* 현재 mail 채널만 사용. 향후 sms 등 확장 시 row 추가만으로 가능.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('identity_message_templates', function (Blueprint $table) {
|
||||
$table->id()->comment('ID');
|
||||
$table->foreignId('definition_id')
|
||||
->constrained('identity_message_definitions')
|
||||
->cascadeOnDelete()
|
||||
->comment('메시지 정의 ID (FK)');
|
||||
$table->string('channel', 20)->comment('메시지 템플릿 채널 (mail 현재 / sms 등 향후) — IdentityVerificationChannel 과는 별개의 도메인 분류');
|
||||
$table->text('subject')->nullable()
|
||||
->comment('다국어 제목 ({"ko":"...", "en":"..."}) — mail 채널에서만 의미');
|
||||
$table->mediumText('body')->comment('다국어 본문 ({"ko":"...", "en":"..."})');
|
||||
$table->boolean('is_active')->default(true)->comment('해당 채널 활성 여부');
|
||||
$table->boolean('is_default')->default(true)->comment('시더 생성 여부 (운영자 편집 시 false)');
|
||||
$table->text('user_overrides')->nullable()
|
||||
->comment('운영자가 수정한 필드명 목록 (예: ["subject","body","is_active"])');
|
||||
$table->foreignId('updated_by')
|
||||
->nullable()
|
||||
->constrained('users')
|
||||
->nullOnDelete()
|
||||
->comment('수정자 (사용자 삭제 시 NULL)');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['definition_id', 'channel'], 'idx_identity_message_tpl_def_channel_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 본인인증 메시지 템플릿 테이블 삭제.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('identity_message_templates');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 보안 환경설정의 로그인 시도 제한·차단 시간을 실제로 강제하기 위한
|
||||
* users 테이블 컬럼 3종을 추가합니다.
|
||||
*
|
||||
* - failed_login_attempts: 연속 실패 카운트 (성공 또는 잠금 시 0 으로 리셋)
|
||||
* - locked_until: 계정 잠금 해제 시각 (NULL = 잠금 없음)
|
||||
* - last_failed_login_at: 마지막 실패 시각 (감사 로그 / 카운트 윈도우 판정 보조)
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('failed_login_attempts')
|
||||
->default(0)
|
||||
->after('blocked_at')
|
||||
->comment('연속 로그인 실패 횟수');
|
||||
|
||||
$table->timestamp('locked_until')
|
||||
->nullable()
|
||||
->after('failed_login_attempts')
|
||||
->comment('계정 잠금 해제 시각 (NULL = 잠금 없음)');
|
||||
|
||||
$table->timestamp('last_failed_login_at')
|
||||
->nullable()
|
||||
->after('locked_until')
|
||||
->comment('마지막 로그인 실패 시각');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'failed_login_attempts',
|
||||
'locked_until',
|
||||
'last_failed_login_at',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 플러그인 테이블에 비활성화 사유 메타 컬럼 추가.
|
||||
*
|
||||
* 사용자 수동 비활성화(manual)와 코어 버전 비호환에 의한 자동 비활성화(incompatible_core)를
|
||||
* 구분하여 (a) UI 라벨링, (b) 알림 영속화, (c) 재호환 시 원클릭 복구 판정에 사용합니다.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('plugins', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('plugins', 'deactivated_reason')) {
|
||||
$table->string('deactivated_reason', 32)
|
||||
->nullable()
|
||||
->after('status')
|
||||
->comment('비활성화 사유: manual(사용자 수동) | incompatible_core(코어 버전 호환성) | null(active)');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('plugins', 'deactivated_at')) {
|
||||
$table->timestamp('deactivated_at')
|
||||
->nullable()
|
||||
->after('deactivated_reason')
|
||||
->comment('비활성화 시점');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('plugins', 'incompatible_required_version')) {
|
||||
$table->string('incompatible_required_version', 64)
|
||||
->nullable()
|
||||
->after('deactivated_at')
|
||||
->comment('incompatible_core 시 요구된 g7_version 제약 (재호환 판정용)');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('plugins', function (Blueprint $table) {
|
||||
$table->index('deactivated_reason', 'plugins_deactivated_reason_index');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 마이그레이션 롤백.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('plugins', function (Blueprint $table) {
|
||||
$table->dropIndex('plugins_deactivated_reason_index');
|
||||
});
|
||||
|
||||
Schema::table('plugins', function (Blueprint $table) {
|
||||
foreach (['incompatible_required_version', 'deactivated_at', 'deactivated_reason'] as $column) {
|
||||
if (Schema::hasColumn('plugins', $column)) {
|
||||
$table->dropColumn($column);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 모듈 테이블에 비활성화 사유 메타 컬럼 추가.
|
||||
*
|
||||
* 사용자 수동 비활성화(manual)와 코어 버전 비호환에 의한 자동 비활성화(incompatible_core)를
|
||||
* 구분하여 (a) UI 라벨링, (b) 알림 영속화, (c) 재호환 시 원클릭 복구 판정에 사용합니다.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('modules', 'deactivated_reason')) {
|
||||
$table->string('deactivated_reason', 32)
|
||||
->nullable()
|
||||
->after('status')
|
||||
->comment('비활성화 사유: manual(사용자 수동) | incompatible_core(코어 버전 호환성) | null(active)');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('modules', 'deactivated_at')) {
|
||||
$table->timestamp('deactivated_at')
|
||||
->nullable()
|
||||
->after('deactivated_reason')
|
||||
->comment('비활성화 시점');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('modules', 'incompatible_required_version')) {
|
||||
$table->string('incompatible_required_version', 64)
|
||||
->nullable()
|
||||
->after('deactivated_at')
|
||||
->comment('incompatible_core 시 요구된 g7_version 제약 (재호환 판정용)');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->index('deactivated_reason', 'modules_deactivated_reason_index');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 마이그레이션 롤백.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->dropIndex('modules_deactivated_reason_index');
|
||||
});
|
||||
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
foreach (['incompatible_required_version', 'deactivated_at', 'deactivated_reason'] as $column) {
|
||||
if (Schema::hasColumn('modules', $column)) {
|
||||
$table->dropColumn($column);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 템플릿 테이블에 비활성화 사유 메타 컬럼 추가.
|
||||
*
|
||||
* 사용자 수동 비활성화(manual)와 코어 버전 비호환에 의한 자동 비활성화(incompatible_core)를
|
||||
* 구분하여 (a) UI 라벨링, (b) 알림 영속화, (c) 재호환 시 원클릭 복구 판정에 사용합니다.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('templates', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('templates', 'deactivated_reason')) {
|
||||
$table->string('deactivated_reason', 32)
|
||||
->nullable()
|
||||
->after('status')
|
||||
->comment('비활성화 사유: manual(사용자 수동) | incompatible_core(코어 버전 호환성) | null(active)');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('templates', 'deactivated_at')) {
|
||||
$table->timestamp('deactivated_at')
|
||||
->nullable()
|
||||
->after('deactivated_reason')
|
||||
->comment('비활성화 시점');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('templates', 'incompatible_required_version')) {
|
||||
$table->string('incompatible_required_version', 64)
|
||||
->nullable()
|
||||
->after('deactivated_at')
|
||||
->comment('incompatible_core 시 요구된 g7_version 제약 (재호환 판정용)');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('templates', function (Blueprint $table) {
|
||||
$table->index('deactivated_reason', 'templates_deactivated_reason_index');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 마이그레이션 롤백.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('templates', function (Blueprint $table) {
|
||||
$table->dropIndex('templates_deactivated_reason_index');
|
||||
});
|
||||
|
||||
Schema::table('templates', function (Blueprint $table) {
|
||||
foreach (['incompatible_required_version', 'deactivated_at', 'deactivated_reason'] as $column) {
|
||||
if (Schema::hasColumn('templates', $column)) {
|
||||
$table->dropColumn($column);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\Concerns;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
|
||||
/**
|
||||
* 코어 시더 보일러플레이트 추상화 — config/core.php SSoT 직독 + lang pack 필터 발화.
|
||||
*
|
||||
* `NotificationDefinitionSeeder`, `IdentityMessageDefinitionSeeder`, `IdentityPolicySeeder` 등
|
||||
* config 의 i18n SSoT 블록을 DB 로 동기화하는 시더가 공통으로 사용하는 패턴을 단일 진입점으로 흡수.
|
||||
*
|
||||
* 사용 예:
|
||||
* $definitions = $this->loadConfigSeed('core.notification_definitions', 'seed.notifications.translations');
|
||||
*
|
||||
* 효과:
|
||||
* - 신규 SSoT 도메인 시더 작성 시 lang pack 필터 호출 누락 자동 방지
|
||||
* - audit 룰 `seeder-translation-filter` 와 정합 (트레이트 사용 = 자동 검증 통과)
|
||||
*
|
||||
* @since 7.0.0-beta.4 (이슈 #263 후속 — Seeder 보일러플레이트 추상화)
|
||||
*/
|
||||
trait LoadsConfigSeedWithLangPackFilter
|
||||
{
|
||||
/**
|
||||
* config 키에서 SSoT 데이터를 로드하고 lang pack 다국어 필터를 적용합니다.
|
||||
*
|
||||
* @param string $configKey config 경로 (예: 'core.notification_definitions')
|
||||
* @param string $filterKey HookManager 필터 키 (예: 'seed.notifications.translations')
|
||||
* @return array<int|string, mixed> 다국어 키가 보강된 SSoT 데이터
|
||||
*/
|
||||
protected function loadConfigSeed(string $configKey, string $filterKey): array
|
||||
{
|
||||
$data = config($configKey, []);
|
||||
|
||||
return HookManager::applyFilters($filterKey, $data);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace Database\Seeders;
|
||||
|
||||
use App\Enums\ExtensionOwnerType;
|
||||
use App\Enums\MenuPermissionType;
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Menu;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
@@ -52,6 +53,9 @@ class CoreAdminMenuSeeder extends Seeder
|
||||
{
|
||||
$coreMenus = config('core.menus');
|
||||
|
||||
// 언어팩 시스템: 활성 코어 언어팩의 seed/menus.json 으로 다국어 키 병합 (§9 필터 주입)
|
||||
$coreMenus = HookManager::applyFilters('core.menus.config', $coreMenus);
|
||||
|
||||
$createdMenus = [];
|
||||
foreach ($coreMenus as $menuData) {
|
||||
$createdMenus[] = Menu::create(array_merge($menuData, [
|
||||
|
||||
@@ -20,6 +20,8 @@ class DatabaseSeeder extends Seeder
|
||||
RolePermissionSeeder::class,
|
||||
CoreAdminMenuSeeder::class,
|
||||
NotificationDefinitionSeeder::class,
|
||||
IdentityPolicySeeder::class,
|
||||
IdentityMessageDefinitionSeeder::class,
|
||||
]);
|
||||
|
||||
// 샘플 시더 (--sample 옵션 시에만 실행)
|
||||
@@ -30,6 +32,7 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call([
|
||||
Sample\DummyUserSeeder::class,
|
||||
Sample\NotificationLogSeeder::class,
|
||||
Sample\IdentityVerificationLogSeeder::class,
|
||||
Sample\TemplateSeeder::class,
|
||||
Sample\TemplateLayoutVersionSeeder::class,
|
||||
Sample\ActivityLogSampleSeeder::class,
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Extension\Helpers\IdentityMessageSyncHelper;
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
* IDV 메시지 정의 시더.
|
||||
*
|
||||
* config/core.php 의 `identity_messages` 블록을 SSoT 로 읽어 DB 로 동기화합니다.
|
||||
* IdentityPolicySeeder / NotificationDefinitionSeeder 와 동일한 config-기반 패턴.
|
||||
*
|
||||
* 운영자가 관리자 UI 에서 수정한 값은 user_overrides 로 보존되어 재시딩 시 덮어써지지 않습니다.
|
||||
*
|
||||
* @since 7.0.0-beta.4
|
||||
*/
|
||||
class IdentityMessageDefinitionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* 시드 실행.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->command?->info('코어 IDV 메시지 정의 시딩 시작...');
|
||||
|
||||
$helper = app(IdentityMessageSyncHelper::class);
|
||||
$definitions = $this->getDefaultDefinitions();
|
||||
|
||||
// 언어팩 시스템: 활성 코어 언어팩의 seed/identity_messages.json 으로 다국어 키 병합.
|
||||
// NotificationDefinitionSeeder 와 동일 패턴.
|
||||
$definitions = HookManager::applyFilters('seed.identity_messages.translations', $definitions);
|
||||
|
||||
$definedScopes = [];
|
||||
|
||||
if (empty($definitions)) {
|
||||
$this->command?->warn('config/core.php 에 identity_messages 선언이 없습니다.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($definitions as $data) {
|
||||
$definition = $helper->syncDefinition($data);
|
||||
$definedScopes[] = [
|
||||
'provider_id' => $definition->provider_id,
|
||||
'scope_type' => $definition->scope_type->value,
|
||||
'scope_value' => $definition->scope_value,
|
||||
];
|
||||
|
||||
$definedChannels = [];
|
||||
foreach ($data['templates'] as $template) {
|
||||
$helper->syncTemplate($definition->id, $template);
|
||||
$definedChannels[] = $template['channel'];
|
||||
}
|
||||
|
||||
$helper->cleanupStaleTemplates($definition->id, $definedChannels);
|
||||
|
||||
$this->command?->info(" - {$definition->provider_id} | {$definition->scope_type->value} | {$definition->scope_value} 등록 완료");
|
||||
}
|
||||
|
||||
$helper->cleanupStaleDefinitions('core', 'core', $definedScopes);
|
||||
|
||||
$this->command?->info('코어 IDV 메시지 정의 시딩 완료 ('.count($definitions).'종)');
|
||||
}
|
||||
|
||||
/**
|
||||
* 코어 기본 메시지 정의 데이터를 config/core.php 에서 조회합니다.
|
||||
*
|
||||
* `extension_type='core'` / `extension_identifier='core'` 자동 주입.
|
||||
* `variables: '__common__'` 마커는 commonVariables() 로 expand.
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
private function getDefaultDefinitions(): array
|
||||
{
|
||||
$messages = config('core.identity_messages', []);
|
||||
$result = [];
|
||||
|
||||
foreach ($messages as $data) {
|
||||
if (($data['variables'] ?? null) === '__common__') {
|
||||
$data['variables'] = $this->commonVariables();
|
||||
}
|
||||
$data['extension_type'] = 'core';
|
||||
$data['extension_identifier'] = 'core';
|
||||
$result[] = $data;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 표준 변수 메타데이터 (모든 mail 정의 공통).
|
||||
*
|
||||
* config/core.php 에서 `'variables' => '__common__'` 마커로 참조됩니다.
|
||||
*
|
||||
* @return array<int, array{key: string, description: string}>
|
||||
*/
|
||||
protected function commonVariables(): array
|
||||
{
|
||||
return [
|
||||
['key' => 'code', 'description' => '인증 코드 (text_code 흐름)'],
|
||||
['key' => 'action_url', 'description' => '검증 링크 URL (link 흐름)'],
|
||||
['key' => 'expire_minutes', 'description' => '만료까지 남은 분'],
|
||||
['key' => 'purpose_label', 'description' => '인증 목적 라벨 (다국어)'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
['key' => 'recipient_email', 'description' => '수신자 이메일'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Extension\Helpers\IdentityPolicySyncHelper;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
* 코어 본인인증 정책을 시딩합니다.
|
||||
*
|
||||
* config/core.php 의 `identity_policies` 블록을 읽어 DB 로 동기화합니다.
|
||||
* 운영자가 S1d UI 에서 수정한 값은 user_overrides 로 보존되어 재시딩 시 덮어써지지 않습니다.
|
||||
*
|
||||
* @since 7.0.0-beta.4
|
||||
*/
|
||||
class IdentityPolicySeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$this->command?->info('코어 본인인증 정책 시딩 시작...');
|
||||
|
||||
$helper = app(IdentityPolicySyncHelper::class);
|
||||
$policies = config('core.identity_policies', []);
|
||||
$definedKeys = [];
|
||||
|
||||
if (empty($policies)) {
|
||||
$this->command?->warn('config/core.php 에 identity_policies 선언이 없습니다.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($policies as $key => $data) {
|
||||
$data = array_merge($data, [
|
||||
'key' => $key,
|
||||
'source_type' => 'core',
|
||||
'source_identifier' => 'core',
|
||||
]);
|
||||
|
||||
$helper->syncPolicy($data);
|
||||
$definedKeys[] = $key;
|
||||
|
||||
$this->command?->line(" ✓ {$key}");
|
||||
}
|
||||
|
||||
$removed = $helper->cleanupStalePolicies('core', 'core', $definedKeys);
|
||||
if ($removed > 0) {
|
||||
$this->command?->line(" - stale 정책 {$removed}개 정리");
|
||||
}
|
||||
|
||||
$this->command?->info('코어 본인인증 정책 시딩 완료: '.count($definedKeys).'개');
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,28 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Extension\Helpers\NotificationSyncHelper;
|
||||
use Database\Seeders\Concerns\LoadsConfigSeedWithLangPackFilter;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
* 코어 알림 정의를 시딩합니다.
|
||||
*
|
||||
* config/core.php 의 `notification_definitions` 블록을 SSoT 로 읽어 DB 로 동기화합니다.
|
||||
* IdentityPolicySeeder 와 동일한 패턴.
|
||||
*
|
||||
* 모듈/플러그인 자체 알림은 각자의 `getNotificationDefinitions()` 에서 선언하며
|
||||
* Manager 가 activate/update 시 자동 동기화하므로 본 시더는 코어 정의만 처리합니다.
|
||||
*
|
||||
* 운영자가 관리자 UI 에서 수정한 값은 user_overrides 로 보존되어 재시딩 시 덮어써지지 않습니다.
|
||||
*
|
||||
* @since 7.0.0-beta.4
|
||||
*/
|
||||
class NotificationDefinitionSeeder extends Seeder
|
||||
{
|
||||
use LoadsConfigSeedWithLangPackFilter;
|
||||
|
||||
/**
|
||||
* 코어 알림 정의 및 템플릿을 시딩합니다.
|
||||
*
|
||||
* 데이터 정합성 (upsert + stale cleanup) 은 NotificationSyncHelper 에 위임하며,
|
||||
* 사용자 수정(user_overrides) 은 helper 내부 HasUserOverrides trait 를 통해 보존됩니다.
|
||||
* 코어 알림 정의 시딩 실행.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -20,207 +33,45 @@ class NotificationDefinitionSeeder extends Seeder
|
||||
$this->command?->info('코어 알림 정의 시딩 시작...');
|
||||
|
||||
$helper = app(NotificationSyncHelper::class);
|
||||
$definitions = $this->getDefaultDefinitions();
|
||||
// config/core.php::notification_definitions + 언어팩 seed/notifications.json 병합
|
||||
$definitions = $this->loadConfigSeed('core.notification_definitions', 'seed.notifications.translations');
|
||||
|
||||
$definedTypes = [];
|
||||
|
||||
foreach ($definitions as $data) {
|
||||
if (empty($definitions)) {
|
||||
$this->command?->warn('config/core.php 에 notification_definitions 선언이 없습니다.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($definitions as $type => $data) {
|
||||
$data = array_merge($data, [
|
||||
'type' => $type,
|
||||
'extension_type' => 'core',
|
||||
'extension_identifier' => 'core',
|
||||
]);
|
||||
|
||||
$definition = $helper->syncDefinition($data);
|
||||
$definedTypes[] = $definition->type;
|
||||
|
||||
$definedChannels = [];
|
||||
foreach ($data['templates'] as $template) {
|
||||
foreach ($data['templates'] ?? [] as $template) {
|
||||
$helper->syncTemplate($definition->id, $template);
|
||||
$definedChannels[] = $template['channel'];
|
||||
}
|
||||
|
||||
// 완전 동기화: seeder 에서 제거된 channel 의 template 삭제
|
||||
// 완전 동기화: config 에서 제거된 channel 의 template 삭제
|
||||
$helper->cleanupStaleTemplates($definition->id, $definedChannels);
|
||||
|
||||
$this->command?->info(" - {$data['type']} 알림 정의 등록 완료");
|
||||
$this->command?->info(" - {$type} 알림 정의 등록 완료");
|
||||
}
|
||||
|
||||
// 완전 동기화: seeder 에서 제거된 코어 definition 삭제 (cascade 로 template 도 정리)
|
||||
$helper->cleanupStaleDefinitions('core', 'core', $definedTypes);
|
||||
// 완전 동기화: config 에서 제거된 코어 definition 삭제 (cascade 로 template 도 정리)
|
||||
$removed = $helper->cleanupStaleDefinitions('core', 'core', $definedTypes);
|
||||
if ($removed > 0) {
|
||||
$this->command?->line(" - stale 정의 {$removed}개 정리");
|
||||
}
|
||||
|
||||
$this->command?->info('코어 알림 정의 시딩 완료 ('.count($definitions).'종)');
|
||||
}
|
||||
|
||||
/**
|
||||
* 코어 기본 알림 정의 데이터를 반환합니다.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultDefinitions(): array
|
||||
{
|
||||
return [
|
||||
$this->welcomeDefinition(),
|
||||
$this->resetPasswordDefinition(),
|
||||
$this->passwordChangedDefinition(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 회원가입 환영 알림 정의.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function welcomeDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'welcome',
|
||||
'hook_prefix' => 'core.auth',
|
||||
'extension_type' => 'core',
|
||||
'extension_identifier' => 'core',
|
||||
'name' => ['ko' => '회원가입 환영', 'en' => 'Welcome'],
|
||||
'description' => ['ko' => '회원가입 완료 시 발송되는 환영 알림', 'en' => 'Welcome notification sent upon registration'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['core.auth.after_register'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'action_url', 'description' => '로그인 페이지 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'trigger_user']],
|
||||
'subject' => [
|
||||
'ko' => '[{app_name}] 회원가입을 환영합니다',
|
||||
'en' => '[{app_name}] Welcome to Our Service',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 환영합니다!</h1>'
|
||||
.'<p>{app_name}에 가입해 주셔서 감사합니다.</p>'
|
||||
.'<p>이제 모든 서비스를 이용하실 수 있습니다. 아래 버튼을 클릭하여 로그인해 주세요.</p>'
|
||||
.'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin: 24px 0;"><tr><td align="center"><a href="{action_url}" style="display: inline-block; padding: 12px 32px; background-color: #2d3748; color: #ffffff; text-decoration: none; border-radius: 4px; font-weight: 600; font-size: 14px;">로그인하기</a></td></tr></table>'
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Welcome, {name}!</h1>'
|
||||
.'<p>Thank you for joining {app_name}.</p>'
|
||||
.'<p>You now have access to all our services. Click the button below to log in.</p>'
|
||||
.'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin: 24px 0;"><tr><td align="center"><a href="{action_url}" style="display: inline-block; padding: 12px 32px; background-color: #2d3748; color: #ffffff; text-decoration: none; border-radius: 4px; font-weight: 600; font-size: 14px;">Log In</a></td></tr></table>'
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'trigger_user']],
|
||||
'subject' => ['ko' => '회원가입을 환영합니다', 'en' => 'Welcome to our service'],
|
||||
'body' => ['ko' => '{name}님, {app_name}에 가입해 주셔서 감사합니다.', 'en' => 'Welcome {name}, thank you for joining {app_name}.'],
|
||||
'click_url' => '/mypage',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 비밀번호 재설정 알림 정의.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function resetPasswordDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'reset_password',
|
||||
'hook_prefix' => 'core.auth',
|
||||
'extension_type' => 'core',
|
||||
'extension_identifier' => 'core',
|
||||
'name' => ['ko' => '비밀번호 재설정', 'en' => 'Password Reset'],
|
||||
'description' => ['ko' => '비밀번호 재설정 요청 시 발송되는 알림', 'en' => 'Notification sent when password reset is requested'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['core.auth.after_reset_password_request'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'action_url', 'description' => '비밀번호 재설정 URL'],
|
||||
['key' => 'expire_minutes', 'description' => '링크 만료 시간(분)'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'trigger_user']],
|
||||
'subject' => [
|
||||
'ko' => '[{app_name}] 비밀번호 재설정 안내',
|
||||
'en' => '[{app_name}] Password Reset Request',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p>비밀번호 재설정 요청을 받았습니다. 아래 버튼을 클릭하여 비밀번호를 재설정해 주세요.</p>'
|
||||
.'<p>이 링크는 <strong>{expire_minutes}분</strong> 후 만료됩니다.</p>'
|
||||
.'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin: 24px 0;"><tr><td align="center"><a href="{action_url}" style="display: inline-block; padding: 12px 32px; background-color: #2d3748; color: #ffffff; text-decoration: none; border-radius: 4px; font-weight: 600; font-size: 14px;">비밀번호 재설정</a></td></tr></table>'
|
||||
.'<p>비밀번호 재설정을 요청하지 않으셨다면, 이 이메일을 무시해 주세요.</p>'
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p>We received a request to reset your password. Click the button below to set a new password.</p>'
|
||||
.'<p>This link will expire in <strong>{expire_minutes} minutes</strong>.</p>'
|
||||
.'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin: 24px 0;"><tr><td align="center"><a href="{action_url}" style="display: inline-block; padding: 12px 32px; background-color: #2d3748; color: #ffffff; text-decoration: none; border-radius: 4px; font-weight: 600; font-size: 14px;">Reset Password</a></td></tr></table>'
|
||||
.'<p>If you did not request a password reset, please ignore this email.</p>'
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'trigger_user']],
|
||||
'subject' => ['ko' => '비밀번호 재설정 안내', 'en' => 'Password Reset Request'],
|
||||
'body' => ['ko' => '{name}님, 비밀번호 재설정이 요청되었습니다. 본인이 요청하지 않았다면 이 알림을 무시해 주세요.', 'en' => '{name}, a password reset has been requested. If you did not request this, please ignore this notification.'],
|
||||
'click_url' => '{action_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 비밀번호 변경 완료 알림 정의.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function passwordChangedDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'password_changed',
|
||||
'hook_prefix' => 'core.auth',
|
||||
'extension_type' => 'core',
|
||||
'extension_identifier' => 'core',
|
||||
'name' => ['ko' => '비밀번호 변경', 'en' => 'Password Changed'],
|
||||
'description' => ['ko' => '비밀번호 변경 완료 시 발송되는 알림', 'en' => 'Notification sent when password is changed'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['core.auth.after_password_changed'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'action_url', 'description' => '로그인 페이지 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'trigger_user']],
|
||||
'subject' => [
|
||||
'ko' => '[{app_name}] 비밀번호가 변경되었습니다',
|
||||
'en' => '[{app_name}] Your Password Has Been Changed',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p>계정의 비밀번호가 성공적으로 변경되었습니다.</p>'
|
||||
.'<p><strong>본인이 변경하지 않았다면, 즉시 고객 지원팀에 문의하시기 바랍니다.</strong></p>'
|
||||
.'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin: 24px 0;"><tr><td align="center"><a href="{action_url}" style="display: inline-block; padding: 12px 32px; background-color: #2d3748; color: #ffffff; text-decoration: none; border-radius: 4px; font-weight: 600; font-size: 14px;">로그인하기</a></td></tr></table>'
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p>Your account password has been successfully changed.</p>'
|
||||
.'<p><strong>If you did not make this change, please contact our support team immediately.</strong></p>'
|
||||
.'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin: 24px 0;"><tr><td align="center"><a href="{action_url}" style="display: inline-block; padding: 12px 32px; background-color: #2d3748; color: #ffffff; text-decoration: none; border-radius: 4px; font-weight: 600; font-size: 14px;">Log In</a></td></tr></table>'
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'trigger_user']],
|
||||
'subject' => ['ko' => '비밀번호가 변경되었습니다', 'en' => 'Your password has been changed'],
|
||||
'body' => ['ko' => '{name}님, 비밀번호가 변경되었습니다. 본인이 변경하지 않았다면 즉시 고객 지원팀에 문의하시기 바랍니다.', 'en' => '{name}, your password has been changed. If you did not make this change, please contact support immediately.'],
|
||||
'click_url' => '/mypage/change-password',
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->command?->info('코어 알림 정의 시딩 완료 ('.count($definedTypes).'종)');
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ namespace Database\Seeders;
|
||||
use App\Enums\ExtensionOwnerType;
|
||||
use App\Enums\PermissionType;
|
||||
use App\Enums\ScopeType;
|
||||
use App\Extension\HookManager;
|
||||
use App\Http\Middleware\PermissionMiddleware;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
@@ -34,6 +36,9 @@ class RolePermissionSeeder extends Seeder
|
||||
$this->assignAdminRole();
|
||||
});
|
||||
|
||||
// guest role 캐시 무효화 — 시드 직후 권한 변경 즉시 반영 (운영: 코어 업데이트/확장 install 후 정합, 테스트: RefreshDatabase 트랜잭션 stale id 회귀 방지)
|
||||
PermissionMiddleware::clearGuestRoleCache();
|
||||
|
||||
$this->command->info('기본 권한과 역할이 성공적으로 생성되었습니다.');
|
||||
}
|
||||
|
||||
@@ -66,6 +71,10 @@ class RolePermissionSeeder extends Seeder
|
||||
private function createHierarchicalPermissions(): void
|
||||
{
|
||||
$permConfig = config('core.permissions');
|
||||
|
||||
// 언어팩 시스템: 활성 코어 언어팩의 seed/permissions.json 으로 다국어 키 병합 (§9 필터 주입)
|
||||
$permConfig = HookManager::applyFilters('core.permissions.config', $permConfig);
|
||||
|
||||
$moduleConfig = $permConfig['module'];
|
||||
|
||||
// 1레벨: 코어 모듈
|
||||
@@ -156,6 +165,9 @@ class RolePermissionSeeder extends Seeder
|
||||
{
|
||||
$roles = config('core.roles');
|
||||
|
||||
// 언어팩 시스템: 활성 코어 언어팩의 seed/roles.json 으로 다국어 키 병합 (§9 필터 주입)
|
||||
$roles = HookManager::applyFilters('core.roles.config', $roles);
|
||||
|
||||
foreach ($roles as $roleDef) {
|
||||
$role = Role::updateOrCreate(
|
||||
['identifier' => $roleDef['identifier']],
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\Sample;
|
||||
|
||||
use App\Database\Sample\AbstractIdentityVerificationLogSampleSeeder;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* 코어 본인인증 이력 샘플 시더.
|
||||
*
|
||||
* source_type='core' 인 IdentityPolicy(auth / profile / account / admin 9종)만 사용하여
|
||||
* 코어 영역 본인인증 이력을 채운다. 모듈 정책은 각 모듈 자체 시더에서 처리.
|
||||
*
|
||||
* 수동 실행:
|
||||
* php artisan db:seed --class="Database\Seeders\Sample\IdentityVerificationLogSeeder"
|
||||
* php artisan db:seed --class="Database\Seeders\Sample\IdentityVerificationLogSeeder" --count=core_identity_verification_logs=300
|
||||
*/
|
||||
class IdentityVerificationLogSeeder extends AbstractIdentityVerificationLogSampleSeeder
|
||||
{
|
||||
/**
|
||||
* 코어 정책만 필터링.
|
||||
*
|
||||
* @param Builder $query IdentityPolicy 쿼리
|
||||
* @return Builder 코어 영역 쿼리
|
||||
*/
|
||||
protected function applyPolicyScope(Builder $query): Builder
|
||||
{
|
||||
return $query->where('source_type', 'core');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string 카운트 옵션 키
|
||||
*/
|
||||
protected function countKey(): string
|
||||
{
|
||||
return 'core_identity_verification_logs';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int 기본 건수
|
||||
*/
|
||||
protected function defaultCount(): int
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string 영역 라벨
|
||||
*/
|
||||
protected function scopeLabel(): string
|
||||
{
|
||||
return '[코어]';
|
||||
}
|
||||
}
|
||||
@@ -2,102 +2,79 @@
|
||||
|
||||
namespace Database\Seeders\Sample;
|
||||
|
||||
use App\Enums\NotificationLogStatus;
|
||||
use App\Models\NotificationLog;
|
||||
use App\Traits\HasSeederCounts;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Database\Sample\AbstractNotificationLogSampleSeeder;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* 알림 발송 이력 개발용 시더
|
||||
* 코어 알림 발송 이력 샘플 시더.
|
||||
*
|
||||
* 다양한 채널/타입의 알림 발송 이력 샘플 데이터를 생성합니다.
|
||||
* 개발/테스트 용도이므로 설치 시 자동 실행되지 않습니다.
|
||||
* extension_type='core' 인 알림 정의(welcome / reset_password / password_changed)
|
||||
* 만 사용하여 코어 영역 발송 이력을 채운다. 모듈 알림은 각 모듈 자체 시더에서 처리.
|
||||
*
|
||||
* 수동 실행:
|
||||
* php artisan db:seed --class="Database\Seeders\Sample\NotificationLogSeeder"
|
||||
* php artisan db:seed --class="Database\Seeders\Sample\NotificationLogSeeder" --count=core_notification_logs=300
|
||||
*/
|
||||
class NotificationLogSeeder extends Seeder
|
||||
class NotificationLogSeeder extends AbstractNotificationLogSampleSeeder
|
||||
{
|
||||
use HasSeederCounts;
|
||||
|
||||
/**
|
||||
* 시더 실행.
|
||||
* 코어 정의만 필터링.
|
||||
*
|
||||
* @return void
|
||||
* @param Builder $query NotificationDefinition 쿼리
|
||||
* @return Builder 코어 영역 쿼리
|
||||
*/
|
||||
public function run(): void
|
||||
protected function applyDefinitionScope(Builder $query): Builder
|
||||
{
|
||||
$count = $this->getSeederCount('notification_logs', 50);
|
||||
|
||||
$this->command->info('알림 발송 이력 시딩 시작...');
|
||||
|
||||
$channels = ['mail', 'database'];
|
||||
$types = [
|
||||
['type' => 'welcome', 'ext_type' => 'core', 'ext_id' => 'core'],
|
||||
['type' => 'reset_password', 'ext_type' => 'core', 'ext_id' => 'core'],
|
||||
['type' => 'password_changed', 'ext_type' => 'core', 'ext_id' => 'core'],
|
||||
['type' => 'order_confirmed', 'ext_type' => 'module', 'ext_id' => 'sirsoft-ecommerce'],
|
||||
['type' => 'order_shipped', 'ext_type' => 'module', 'ext_id' => 'sirsoft-ecommerce'],
|
||||
['type' => 'new_comment', 'ext_type' => 'module', 'ext_id' => 'sirsoft-board'],
|
||||
['type' => 'new_post_admin', 'ext_type' => 'module', 'ext_id' => 'sirsoft-board'],
|
||||
];
|
||||
$recipients = $this->getRecipients();
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$channel = $channels[array_rand($channels)];
|
||||
$typeInfo = $types[array_rand($types)];
|
||||
$recipient = $recipients[array_rand($recipients)];
|
||||
$status = $this->randomStatus();
|
||||
$sentAt = Carbon::now()->subDays(mt_rand(0, 30))->subHours(mt_rand(0, 23))->subMinutes(mt_rand(0, 59));
|
||||
|
||||
NotificationLog::create([
|
||||
'channel' => $channel,
|
||||
'notification_type' => $typeInfo['type'],
|
||||
'extension_type' => $typeInfo['ext_type'],
|
||||
'extension_identifier' => $typeInfo['ext_id'],
|
||||
'recipient_identifier' => $channel === 'mail' ? $recipient['email'] : (string) ($i + 1),
|
||||
'recipient_name' => $recipient['name'],
|
||||
'subject' => "[G7] {$typeInfo['type']} 알림",
|
||||
'status' => $status->value,
|
||||
'error_message' => $status === NotificationLogStatus::Failed ? 'SMTP connection refused' : null,
|
||||
'source' => 'notification',
|
||||
'sent_at' => $sentAt,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->command->info("알림 발송 이력 시딩 완료 ({$count}건)");
|
||||
return $query->where('extension_type', 'core');
|
||||
}
|
||||
|
||||
/**
|
||||
* 샘플 수신자 목록.
|
||||
*
|
||||
* @return array
|
||||
* @return string 카운트 옵션 키
|
||||
*/
|
||||
private function getRecipients(): array
|
||||
protected function countKey(): string
|
||||
{
|
||||
return 'core_notification_logs';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int 기본 건수
|
||||
*/
|
||||
protected function defaultCount(): int
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string 영역 라벨
|
||||
*/
|
||||
protected function scopeLabel(): string
|
||||
{
|
||||
return '[코어]';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function subjectMap(): array
|
||||
{
|
||||
return [
|
||||
['email' => 'hong@example.com', 'name' => '홍길동'],
|
||||
['email' => 'kim@example.com', 'name' => '김철수'],
|
||||
['email' => 'lee@example.com', 'name' => '이영희'],
|
||||
['email' => 'park@example.com', 'name' => '박민수'],
|
||||
['email' => 'john@example.com', 'name' => 'John Doe'],
|
||||
['email' => 'jane@example.com', 'name' => 'Jane Smith'],
|
||||
'welcome' => '[G7] 회원가입을 환영합니다',
|
||||
'reset_password' => '[G7] 비밀번호 재설정 안내',
|
||||
'password_changed' => '[G7] 비밀번호가 변경되었습니다',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 가중치 기반 랜덤 상태.
|
||||
*
|
||||
* @return NotificationLogStatus
|
||||
* @return array<string, callable(User, Carbon): string>
|
||||
*/
|
||||
private function randomStatus(): NotificationLogStatus
|
||||
protected function bodyMap(): array
|
||||
{
|
||||
$rand = mt_rand(1, 100);
|
||||
|
||||
if ($rand <= 80) {
|
||||
return NotificationLogStatus::Sent;
|
||||
} elseif ($rand <= 95) {
|
||||
return NotificationLogStatus::Failed;
|
||||
}
|
||||
|
||||
return NotificationLogStatus::Skipped;
|
||||
return [
|
||||
'welcome' => fn (User $u, Carbon $t) => "안녕하세요 {$u->name}님,\n\nG7에 가입해 주셔서 감사합니다.\n다양한 기능을 자유롭게 이용하실 수 있도록 도와드리겠습니다.\n\n감사합니다.\nG7 팀 드림",
|
||||
'reset_password' => fn (User $u, Carbon $t) => "안녕하세요 {$u->name}님,\n\n비밀번호 재설정 요청이 접수되었습니다.\n아래 링크를 클릭하여 새 비밀번호를 설정해 주세요.\n링크는 30분간 유효합니다.\n\n본인이 요청하지 않으셨다면 이 메일을 무시하셔도 됩니다.",
|
||||
'password_changed' => fn (User $u, Carbon $t) => "안녕하세요 {$u->name}님,\n\n계정 비밀번호가 정상적으로 변경되었습니다.\n변경 일시: {$t->format('Y-m-d H:i')}\n\n본인이 변경하지 않으셨다면 즉시 고객센터로 문의해 주세요.",
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user