v7.0.0-beta.1 release

This commit is contained in:
HeuJung committed 2026-04-01 10:30:52 +09:00
commit 6595fd0eb5
3967 files changed
+1875383

No files matched your search

+173
View File
@@ -0,0 +1,173 @@
<?php
namespace Database\Factories;
use App\Enums\AttachmentSourceType;
use App\Models\Attachment;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* 첨부파일 팩토리
*
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Attachment>
*/
class AttachmentFactory extends Factory
{
/**
* 모델 클래스
*
* @var string
*/
protected $model = Attachment::class;
/**
* 기본 상태 정의
*
* @return array<string, mixed>
*/
public function definition(): array
{
$filename = $this->faker->word() . '.jpg';
$storedFilename = Str::uuid() . '.jpg';
return [
'attachmentable_type' => null,
'attachmentable_id' => null,
'source_type' => AttachmentSourceType::Core,
'source_identifier' => null,
'hash' => Str::random(12),
'original_filename' => $filename,
'stored_filename' => $storedFilename,
'disk' => 'local',
'path' => 'attachments/' . date('Y/m/d') . '/' . $storedFilename,
'mime_type' => 'image/jpeg',
'size' => $this->faker->numberBetween(1024, 1024 * 1024),
'collection' => 'default',
'order' => 0,
'meta' => null,
'created_by' => null,
];
}
/**
* 이미지 첨부파일
*/
public function image(): static
{
return $this->state(fn (array $attributes) => [
'mime_type' => $this->faker->randomElement(['image/jpeg', 'image/png', 'image/gif', 'image/webp']),
'original_filename' => $this->faker->word() . '.' . $this->faker->randomElement(['jpg', 'png', 'gif', 'webp']),
'meta' => [
'width' => $this->faker->numberBetween(100, 1920),
'height' => $this->faker->numberBetween(100, 1080),
],
]);
}
/**
* PDF 첨부파일
*/
public function pdf(): static
{
$filename = $this->faker->word() . '.pdf';
$storedFilename = Str::uuid() . '.pdf';
return $this->state(fn (array $attributes) => [
'mime_type' => 'application/pdf',
'original_filename' => $filename,
'stored_filename' => $storedFilename,
'path' => 'attachments/' . date('Y/m/d') . '/' . $storedFilename,
]);
}
/**
* 문서 첨부파일
*/
public function document(): static
{
$extension = $this->faker->randomElement(['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']);
$filename = $this->faker->word() . '.' . $extension;
$storedFilename = Str::uuid() . '.' . $extension;
$mimeTypes = [
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xls' => 'application/vnd.ms-excel',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'ppt' => 'application/vnd.ms-powerpoint',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
];
return $this->state(fn (array $attributes) => [
'mime_type' => $mimeTypes[$extension],
'original_filename' => $filename,
'stored_filename' => $storedFilename,
'path' => 'attachments/' . date('Y/m/d') . '/' . $storedFilename,
]);
}
/**
* 특정 사용자가 업로드한 상태
*/
public function uploadedBy(User $user): static
{
return $this->state(fn (array $attributes) => [
'created_by' => $user->id,
]);
}
/**
* 특정 컬렉션 지정
*/
public function inCollection(string $collection): static
{
return $this->state(fn (array $attributes) => [
'collection' => $collection,
]);
}
/**
* 모듈 소스 타입
*/
public function fromModule(string $identifier): static
{
return $this->state(fn (array $attributes) => [
'source_type' => AttachmentSourceType::Module,
'source_identifier' => $identifier,
]);
}
/**
* 플러그인 소스 타입
*/
public function fromPlugin(string $identifier): static
{
return $this->state(fn (array $attributes) => [
'source_type' => AttachmentSourceType::Plugin,
'source_identifier' => $identifier,
]);
}
/**
* 특정 모델에 첨부
*/
public function attachedTo(string $type, int $id): static
{
return $this->state(fn (array $attributes) => [
'attachmentable_type' => $type,
'attachmentable_id' => $id,
]);
}
/**
* 정렬 순서 지정
*/
public function withOrder(int $order): static
{
return $this->state(fn (array $attributes) => [
'order' => $order,
]);
}
}
@@ -0,0 +1,163 @@
<?php
namespace Database\Factories;
use App\Enums\LayoutExtensionType;
use App\Enums\LayoutSourceType;
use App\Models\LayoutExtension;
use App\Models\Template;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<LayoutExtension>
*/
class LayoutExtensionFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var class-string<LayoutExtension>
*/
protected $model = LayoutExtension::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$vendor = fake()->randomElement(['sirsoft', 'acme', 'demo']);
return [
'template_id' => Template::factory(),
'extension_type' => fake()->randomElement(LayoutExtensionType::cases()),
'target_name' => fake()->randomElement(['sidebar-top', 'sidebar-bottom', 'header-actions', 'admin/dashboard', 'admin/settings']),
'source_type' => fake()->randomElement(LayoutSourceType::cases()),
'source_identifier' => $vendor.'-'.fake()->slug(1),
'content' => $this->generateExtensionData(),
'priority' => fake()->numberBetween(1, 100),
'is_active' => true,
'override_target' => null,
];
}
/**
* 확장 데이터 생성
*
* @return array
*/
private function generateExtensionData(): array
{
return [
'component' => [
'type' => 'basic',
'name' => fake()->randomElement(['Button', 'Div', 'Card', 'Alert']),
'props' => [
'className' => 'test-class',
],
],
];
}
/**
* Extension Point 타입 상태
*/
public function extensionPoint(): static
{
return $this->state(fn (array $attributes) => [
'extension_type' => LayoutExtensionType::ExtensionPoint,
]);
}
/**
* Overlay 타입 상태
*/
public function overlay(): static
{
return $this->state(fn (array $attributes) => [
'extension_type' => LayoutExtensionType::Overlay,
'content' => [
'target_component_id' => 'component-'.fake()->uuid(),
'position' => fake()->randomElement(['append_child', 'prepend', 'replace']),
'component' => [
'type' => 'basic',
'name' => 'Div',
],
],
]);
}
/**
* 모듈 출처 상태
*/
public function fromModule(string $identifier = null): static
{
return $this->state(fn (array $attributes) => [
'source_type' => LayoutSourceType::Module,
'source_identifier' => $identifier ?? 'sirsoft-ecommerce',
]);
}
/**
* 플러그인 출처 상태
*/
public function fromPlugin(string $identifier = null): static
{
return $this->state(fn (array $attributes) => [
'source_type' => LayoutSourceType::Plugin,
'source_identifier' => $identifier ?? 'sirsoft-analytics',
]);
}
/**
* 템플릿 출처 상태 (오버라이드용)
*/
public function fromTemplate(string $identifier = null): static
{
return $this->state(fn (array $attributes) => [
'source_type' => LayoutSourceType::Template,
'source_identifier' => $identifier ?? 'sirsoft-admin_basic',
]);
}
/**
* 오버라이드 타겟 설정
*/
public function overriding(string $targetIdentifier): static
{
return $this->state(fn (array $attributes) => [
'override_target' => $targetIdentifier,
]);
}
/**
* 비활성 상태
*/
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => false,
]);
}
/**
* 우선순위 설정
*/
public function withPriority(int $priority): static
{
return $this->state(fn (array $attributes) => [
'priority' => $priority,
]);
}
/**
* 특정 타겟 설정
*/
public function targeting(string $targetName): static
{
return $this->state(fn (array $attributes) => [
'target_name' => $targetName,
]);
}
}
+83
View File
@@ -0,0 +1,83 @@
<?php
namespace Database\Factories;
use App\Enums\ExtensionOwnerType;
use App\Enums\MailSendStatus;
use App\Models\MailSendLog;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* 메일 발송 이력 팩토리
*
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\MailSendLog>
*/
class MailSendLogFactory extends Factory
{
/**
* 모델 클래스
*
* @var string
*/
protected $model = MailSendLog::class;
/**
* 기본 상태 정의
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'sender_email' => $this->faker->safeEmail(),
'sender_name' => $this->faker->name(),
'recipient_email' => $this->faker->safeEmail(),
'recipient_name' => $this->faker->name(),
'subject' => $this->faker->sentence(),
'body' => '<p>'.$this->faker->paragraph().'</p>',
'template_type' => $this->faker->randomElement(['welcome', 'password_reset', 'new_comment']),
'extension_type' => ExtensionOwnerType::Core->value,
'extension_identifier' => 'core',
'source' => $this->faker->randomElement(['notification', 'test_mail', null]),
'status' => MailSendStatus::Sent->value,
'error_message' => null,
'sent_at' => now(),
];
}
/**
* 발송 실패 상태
*/
public function failed(): static
{
return $this->state(fn (array $attributes) => [
'status' => MailSendStatus::Failed->value,
'error_message' => $this->faker->sentence(),
]);
}
/**
* 특정 확장 지정
*
* @param ExtensionOwnerType $type 확장 타입
* @param string $identifier 확장 식별자
* @return static
*/
public function forExtension(ExtensionOwnerType $type, string $identifier): static
{
return $this->state(fn (array $attributes) => [
'extension_type' => $type->value,
'extension_identifier' => $identifier,
]);
}
/**
* 특정 템플릿 유형 지정
*/
public function withTemplateType(string $templateType): static
{
return $this->state(fn (array $attributes) => [
'template_type' => $templateType,
]);
}
}
@@ -0,0 +1,90 @@
<?php
namespace Database\Factories;
use App\Models\MailTemplate;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* MailTemplate 팩토리
*
* @extends Factory<MailTemplate>
*/
class MailTemplateFactory extends Factory
{
/**
* @var string 팩토리 모델 클래스
*/
protected $model = MailTemplate::class;
/**
* 기본 상태를 정의합니다.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'type' => $this->faker->unique()->slug(2),
'subject' => [
'ko' => '[테스트] '.$this->faker->sentence(),
'en' => '[Test] '.$this->faker->sentence(),
],
'body' => [
'ko' => '<p>'.$this->faker->paragraph().'</p>',
'en' => '<p>'.$this->faker->paragraph().'</p>',
],
'variables' => [
['key' => 'name', 'description' => '수신자 이름'],
['key' => 'app_name', 'description' => '사이트명'],
],
'is_active' => true,
'is_default' => true,
'updated_by' => null,
];
}
/**
* 비활성 상태
*
* @return static
*/
public function inactive(): static
{
return $this->state(fn () => ['is_active' => false]);
}
/**
* 특정 유형
*
* @param string $type 템플릿 유형
* @return static
*/
public function withType(string $type): static
{
return $this->state(fn () => ['type' => $type]);
}
/**
* 변수 포함 본문
*
* @return static
*/
public function withVariables(): static
{
return $this->state(fn () => [
'subject' => [
'ko' => '[{app_name}] {name}님 환영합니다',
'en' => '[{app_name}] Welcome {name}',
],
'body' => [
'ko' => '<p>{name}님, {app_name}에 가입해 주셔서 감사합니다.</p>',
'en' => '<p>Welcome {name}, thank you for joining {app_name}.</p>',
],
'variables' => [
['key' => 'name', 'description' => '수신자 이름'],
['key' => 'app_name', 'description' => '사이트명'],
],
]);
}
}
+87
View File
@@ -0,0 +1,87 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Menu>
*/
class MenuFactory extends Factory
{
/**
* 다국어 필드 생성
*/
protected function generateTranslatableField(callable $generator): array
{
$locales = config('app.translatable_locales', ['ko', 'en']);
$data = [];
foreach ($locales as $locale) {
$data[$locale] = $generator();
}
return $data;
}
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->generateTranslatableField(fn () => $this->faker->words(2, true)),
'slug' => $this->faker->unique()->slug(),
'url' => '/admin/'.$this->faker->slug(),
'icon' => 'fas fa-'.$this->faker->randomElement(['home', 'user', 'cog', 'chart', 'file']),
'parent_id' => null,
'order' => $this->faker->numberBetween(1, 100),
'is_active' => true,
'module_id' => null,
'created_by' => User::factory(),
];
}
/**
* 비활성화된 메뉴 상태
*/
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => false,
]);
}
/**
* 모듈 메뉴 상태
*/
public function moduleMenu(int $moduleId = 1): static
{
return $this->state(fn (array $attributes) => [
'module_id' => $moduleId,
]);
}
/**
* 자식 메뉴 상태
*/
public function childMenu(int $parentId): static
{
return $this->state(fn (array $attributes) => [
'parent_id' => $parentId,
]);
}
/**
* 코어 메뉴 상태 (기본값과 동일하지만 명시적)
*/
public function coreMenu(): static
{
return $this->state(fn (array $attributes) => [
'module_id' => null,
]);
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Module>
*/
class ModuleFactory extends Factory
{
/**
* 다국어 필드 생성
*/
protected function generateTranslatableField(callable $generator): array
{
$locales = config('app.translatable_locales', ['ko', 'en']);
$data = [];
foreach ($locales as $locale) {
$data[$locale] = $generator();
}
return $data;
}
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'identifier' => $this->faker->unique()->slug(2),
'vendor' => $this->faker->word(),
'name' => $this->generateTranslatableField(fn () => $this->faker->words(2, true)),
'version' => $this->faker->numerify('#.#.#'),
'status' => 'active',
'description' => $this->generateTranslatableField(fn () => $this->faker->sentence()),
'config' => null,
'metadata' => null,
'created_by' => null,
'updated_by' => null,
];
}
}
+99
View File
@@ -0,0 +1,99 @@
<?php
namespace Database\Factories;
use App\Enums\ExtensionOwnerType;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Permission>
*/
class PermissionFactory extends Factory
{
/**
* 다국어 필드 생성
*/
protected function generateTranslatableField(callable $generator): array
{
$locales = config('app.translatable_locales', ['ko', 'en']);
$data = [];
foreach ($locales as $locale) {
$data[$locale] = $generator();
}
return $data;
}
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'identifier' => $this->faker->unique()->slug(2),
'name' => $this->generateTranslatableField(fn () => $this->faker->words(2, true)),
'description' => $this->generateTranslatableField(fn () => $this->faker->sentence()),
'extension_type' => null,
'extension_identifier' => null,
];
}
/**
* 시스템(코어) 권한 상태
*/
public function system(): static
{
return $this->core();
}
/**
* 코어 권한 상태
*/
public function core(): static
{
return $this->state(fn (array $attributes) => [
'extension_type' => ExtensionOwnerType::Core,
'extension_identifier' => 'core',
]);
}
/**
* 사용자 관리 권한 상태
*/
public function userManagement(): static
{
return $this->state(fn (array $attributes) => [
'extension_type' => ExtensionOwnerType::Core,
'extension_identifier' => 'core',
]);
}
/**
* 모듈 권한 상태
*
* @param string $identifier 모듈 식별자
*/
public function forModule(string $identifier): static
{
return $this->state(fn (array $attributes) => [
'extension_type' => ExtensionOwnerType::Module,
'extension_identifier' => $identifier,
]);
}
/**
* 플러그인 권한 상태
*
* @param string $identifier 플러그인 식별자
*/
public function forPlugin(string $identifier): static
{
return $this->state(fn (array $attributes) => [
'extension_type' => ExtensionOwnerType::Plugin,
'extension_identifier' => $identifier,
]);
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Plugin>
*/
class PluginFactory extends Factory
{
/**
* 다국어 필드 생성
*/
protected function generateTranslatableField(callable $generator): array
{
$locales = config('app.translatable_locales', ['ko', 'en']);
$data = [];
foreach ($locales as $locale) {
$data[$locale] = $generator();
}
return $data;
}
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'identifier' => $this->faker->unique()->slug(2),
'vendor' => $this->faker->word(),
'name' => $this->generateTranslatableField(fn () => $this->faker->words(2, true)),
'version' => $this->faker->numerify('#.#.#'),
'latest_version' => null,
'description' => $this->generateTranslatableField(fn () => $this->faker->sentence()),
'status' => 'active',
'update_available' => false,
'hooks' => null,
'github_url' => null,
'github_changelog_url' => null,
'metadata' => null,
'created_by' => null,
'updated_by' => null,
];
}
}
+125
View File
@@ -0,0 +1,125 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Role>
*/
class RoleFactory extends Factory
{
/**
* 다국어 필드 생성
*/
protected function generateTranslatableField(callable $generator): array
{
$locales = config('app.translatable_locales', ['ko', 'en']);
$data = [];
foreach ($locales as $locale) {
$data[$locale] = $generator();
}
return $data;
}
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'identifier' => $this->faker->unique()->slug(1),
'name' => $this->generateTranslatableField(fn () => $this->faker->words(2, true)),
'description' => $this->generateTranslatableField(fn () => $this->faker->sentence()),
'is_active' => true,
];
}
/**
* 비활성화된 역할 상태
*/
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => false,
]);
}
/**
* 관리자 역할
*/
public function admin(): static
{
// 기본 번역 정의
$defaultTranslations = [
'name' => [
'ko' => '관리자',
'en' => 'Administrator',
],
'description' => [
'ko' => '시스템의 모든 권한을 가진 관리자입니다.',
'en' => 'Full system administrator with all permissions.',
],
];
// config에서 로케일 가져오기
$locales = config('app.translatable_locales', ['ko', 'en']);
$nameTranslations = [];
$descriptionTranslations = [];
foreach ($locales as $locale) {
// 정의된 번역이 있으면 사용, 없으면 영어 fallback
$nameTranslations[$locale] = $defaultTranslations['name'][$locale]
?? $defaultTranslations['name']['en'];
$descriptionTranslations[$locale] = $defaultTranslations['description'][$locale]
?? $defaultTranslations['description']['en'];
}
return $this->state(fn (array $attributes) => [
'identifier' => 'admin',
'name' => $nameTranslations,
'description' => $descriptionTranslations,
]);
}
/**
* 편집자 역할
*/
public function editor(): static
{
// 기본 번역 정의
$defaultTranslations = [
'name' => [
'ko' => '편집자',
'en' => 'Editor',
],
'description' => [
'ko' => '콘텐츠를 편집할 수 있는 편집자입니다.',
'en' => 'Content editor with editing permissions.',
],
];
// config에서 로케일 가져오기
$locales = config('app.translatable_locales', ['ko', 'en']);
$nameTranslations = [];
$descriptionTranslations = [];
foreach ($locales as $locale) {
// 정의된 번역이 있으면 사용, 없으면 영어 fallback
$nameTranslations[$locale] = $defaultTranslations['name'][$locale]
?? $defaultTranslations['name']['en'];
$descriptionTranslations[$locale] = $defaultTranslations['description'][$locale]
?? $defaultTranslations['description']['en'];
}
return $this->state(fn (array $attributes) => [
'identifier' => 'editor',
'name' => $nameTranslations,
'description' => $descriptionTranslations,
]);
}
}
+98
View File
@@ -0,0 +1,98 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Template>
*/
class TemplateFactory extends Factory
{
/**
* 다국어 필드 생성
*/
protected function generateTranslatableField(callable $generator): array
{
$locales = config('app.translatable_locales', ['ko', 'en']);
$data = [];
foreach ($locales as $locale) {
$data[$locale] = $generator();
}
return $data;
}
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$vendor = fake()->randomElement(['sirsoft', 'johndoe', 'acmecorp']);
$type = fake()->randomElement(['admin', 'user']);
return [
'identifier' => $vendor.'-'.fake()->slug(2),
'vendor' => $vendor,
'name' => $this->generateTranslatableField(fn () => fake()->words(2, true)),
'version' => fake()->semver(),
'latest_version' => fake()->semver(),
'update_available' => fake()->boolean(30),
'type' => $type,
'status' => fake()->randomElement(['active', 'inactive']),
'description' => $this->generateTranslatableField(fn () => fake()->sentence()),
'user_modified_at' => fake()->boolean(50) ? fake()->dateTime() : null,
'github_url' => fake()->url(),
'github_changelog_url' => fake()->url(),
'metadata' => [
'author' => fake()->name(),
'license' => 'MIT',
],
'created_by' => null,
'updated_by' => null,
];
}
/**
* 한국어만 있는 템플릿 상태
*/
public function koreanOnly(): static
{
$locales = config('app.translatable_locales', ['ko', 'en']);
$nameTranslations = [];
$descriptionTranslations = [];
foreach ($locales as $locale) {
$nameTranslations[$locale] = $locale === 'ko' ? fake()->words(2, true) : '';
$descriptionTranslations[$locale] = $locale === 'ko' ? fake()->sentence() : '';
}
return $this->state(fn (array $attributes) => [
'name' => $nameTranslations,
'description' => $descriptionTranslations,
]);
}
/**
* 영어만 있는 템플릿 상태
*/
public function englishOnly(): static
{
$locales = config('app.translatable_locales', ['ko', 'en']);
$nameTranslations = [];
$descriptionTranslations = [];
foreach ($locales as $locale) {
$nameTranslations[$locale] = $locale === 'en' ? fake()->words(2, true) : '';
$descriptionTranslations[$locale] = $locale === 'en' ? fake()->sentence() : '';
}
return $this->state(fn (array $attributes) => [
'name' => $nameTranslations,
'description' => $descriptionTranslations,
]);
}
}
@@ -0,0 +1,73 @@
<?php
namespace Database\Factories;
use App\Enums\LayoutSourceType;
use App\Models\Template;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TemplateLayout>
*/
class TemplateLayoutFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
// 유니크 제약조건 (template_id, name, source_type)을 위해 고유한 name 생성
$layoutName = fake()->unique()->slug(3);
return [
'template_id' => Template::factory(),
'name' => $layoutName,
'content' => [
'version' => '1.0.0',
'layout_name' => $layoutName,
'endpoint' => '/api/'.fake()->word(),
'components' => [],
'data_sources' => [],
'metadata' => [],
],
'extends' => null,
'source_type' => LayoutSourceType::Template,
'source_identifier' => null,
];
}
/**
* 모듈 소스 타입으로 설정
*/
public function fromModule(string $moduleIdentifier): static
{
return $this->state(fn (array $attributes) => [
'source_type' => LayoutSourceType::Module,
'source_identifier' => $moduleIdentifier,
]);
}
/**
* 플러그인 소스 타입으로 설정
*/
public function fromPlugin(string $pluginIdentifier): static
{
return $this->state(fn (array $attributes) => [
'source_type' => LayoutSourceType::Plugin,
'source_identifier' => $pluginIdentifier,
]);
}
/**
* 템플릿 오버라이드로 설정
*/
public function asOverride(string $templateIdentifier): static
{
return $this->state(fn (array $attributes) => [
'source_type' => LayoutSourceType::Template,
'source_identifier' => $templateIdentifier,
]);
}
}
@@ -0,0 +1,36 @@
<?php
namespace Database\Factories;
use App\Models\TemplateLayout;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TemplateLayoutVersion>
*/
class TemplateLayoutVersionFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'layout_id' => TemplateLayout::factory(),
'version' => fake()->unique()->numberBetween(1, 1000),
'content' => [
'version' => '1.0.0',
'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,
]),
];
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'uuid' => Str::orderedUuid()->toString(),
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'is_super' => false,
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}