v7.0.0-beta.1 release

This commit is contained in:
HeuJung
2026-04-01 10:30:52 +09:00
commit 6595fd0eb5
3967 changed files with 1875383 additions and 0 deletions
@@ -0,0 +1,84 @@
<?php
namespace App\Http\Requests\Module;
use App\Enums\ExtensionStatus;
use App\Extension\HookManager;
use App\Rules\TranslatableField;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
/**
* 모듈 업데이트 요청 검증
*
* 모듈의 name, description, status를 업데이트할 수 있습니다.
* name과 description은 다국어 필드로 처리됩니다.
*/
class UpdateModuleRequest extends FormRequest
{
/**
* 사용자가 이 요청을 수행할 권한이 있는지 확인
*
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
*/
public function authorize(): bool
{
return true;
}
/**
* 검증 전 데이터 전처리
*
* 역호환성을 위해 문자열로 들어온 name, description을
* 다국어 배열 형식으로 자동 변환합니다.
*/
protected function prepareForValidation(): void
{
$locales = config('app.translatable_locales', ['ko', 'en']);
// name이 문자열로 들어온 경우 배열로 변환 (역호환성)
if ($this->has('name') && is_string($this->name)) {
$nameArray = [];
foreach ($locales as $locale) {
$nameArray[$locale] = $this->name;
}
$this->merge(['name' => $nameArray]);
}
// description이 문자열로 들어온 경우 배열로 변환
if ($this->has('description') && is_string($this->description)) {
$descriptionArray = [];
foreach ($locales as $locale) {
$descriptionArray[$locale] = $this->description;
}
$this->merge(['description' => $descriptionArray]);
}
}
/**
* 요청에 적용할 검증 규칙
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$rules = [
'name' => ['nullable', new TranslatableField(maxLength: 255)],
'description' => ['nullable', new TranslatableField(maxLength: 1000)],
'status' => ['nullable', 'string', Rule::in(ExtensionStatus::values())],
];
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
return HookManager::applyFilters('core.module.update_validation_rules', $rules, $this);
}
/**
* 검증 오류 메시지 커스터마이징
*/
public function messages(): array
{
return [
'status.in' => __('validation.module.status.in'),
];
}
}