v7.0.0-beta.1 release
This commit is contained in:
commit
6595fd0eb5
3967 files changed
+1875383
No files matched your search
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ActivityLog;
|
||||
|
||||
use App\Models\ActivityLog;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 활동 로그 일괄 삭제 요청을 검증합니다.
|
||||
*/
|
||||
class ActivityLogBulkDeleteRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 항상 true (권한은 permission 미들웨어에서 처리)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 유효성 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'ids' => ['required', 'array', 'min:1'],
|
||||
'ids.*' => ['required', 'integer', Rule::exists(ActivityLog::class, 'id')],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 사용자 정의 유효성 검증 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string> 메시지
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'ids.required' => __('activity_log.validation.ids_required'),
|
||||
'ids.min' => __('activity_log.validation.ids_min'),
|
||||
'ids.*.exists' => __('activity_log.validation.id_not_found'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ActivityLog;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 활동 로그 삭제 요청을 검증합니다.
|
||||
*/
|
||||
class ActivityLogDeleteRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 항상 true (권한은 permission 미들웨어에서 처리)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 유효성 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ActivityLog;
|
||||
|
||||
use App\Enums\ActivityLogType;
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 활동 로그 목록 조회 요청을 검증합니다.
|
||||
*/
|
||||
class ActivityLogIndexRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 항상 true (권한은 permission 미들웨어에서 처리)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 유효성 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'log_type' => ['nullable', 'array'],
|
||||
'log_type.*' => ['string', Rule::in(ActivityLogType::values())],
|
||||
'action' => ['nullable', 'string', 'max:100'],
|
||||
'user_id' => ['nullable', 'integer', Rule::exists('users', 'id')],
|
||||
'loggable_type' => ['nullable', 'string', 'max:255'],
|
||||
'search' => ['nullable', 'string', 'max:255'],
|
||||
'search_type' => ['nullable', 'string', Rule::in(['all', 'action', 'description', 'ip_address'])],
|
||||
'created_by' => ['nullable', 'string', 'max:36'],
|
||||
'date_from' => ['nullable', 'date'],
|
||||
'date_to' => ['nullable', 'date', 'after_or_equal:date_from'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||
'sort_by' => ['nullable', 'string', Rule::in(['created_at', 'action', 'log_type'])],
|
||||
'sort_order' => ['nullable', 'string', Rule::in(['asc', 'desc'])],
|
||||
];
|
||||
|
||||
return HookManager::applyFilters('core.activity_log.index_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 사용자 정의 유효성 검증 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string> 메시지
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'log_type.*.in' => __('activity_log.validation.log_type_invalid'),
|
||||
'date_to.after_or_equal' => __('activity_log.validation.date_range_invalid'),
|
||||
'per_page.min' => __('activity_log.validation.per_page_min'),
|
||||
'per_page.max' => __('activity_log.validation.per_page_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* SEO 캐시 삭제 요청 검증
|
||||
*
|
||||
* 캐시 삭제 시 레이아웃/모듈 필터 파라미터를 검증합니다.
|
||||
*/
|
||||
class SeoCacheClearRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인합니다.
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*
|
||||
* @return bool 항상 true
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, array<int, string>> 검증 규칙 배열
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'layout' => ['nullable', 'string'],
|
||||
'module' => ['nullable', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 에러 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string> 에러 메시지 배열
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'layout.string' => __('validation.string', ['attribute' => __('validation.attributes.layout')]),
|
||||
'module.string' => __('validation.string', ['attribute' => __('validation.attributes.module')]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Extension\PluginManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 플러그인 설정 업데이트 요청 검증
|
||||
*
|
||||
* 플러그인의 설정 스키마를 기반으로 동적으로 유효성 검사 규칙을 생성합니다.
|
||||
*/
|
||||
class UpdatePluginSettingsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인합니다.
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*
|
||||
* @return bool 항상 true
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙을 반환합니다.
|
||||
*
|
||||
* 플러그인의 설정 스키마를 기반으로 동적으로 규칙을 생성합니다.
|
||||
*
|
||||
* @return array 검증 규칙 배열
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$identifier = $this->route('identifier');
|
||||
$pluginManager = app(PluginManager::class);
|
||||
$plugin = $pluginManager->getPlugin($identifier);
|
||||
|
||||
if (! $plugin) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$schema = $plugin->getSettingsSchema();
|
||||
$rules = [];
|
||||
|
||||
foreach ($schema as $field => $config) {
|
||||
$fieldRules = [];
|
||||
|
||||
// 필수 여부
|
||||
if ($config['required'] ?? false) {
|
||||
$fieldRules[] = 'required';
|
||||
} else {
|
||||
$fieldRules[] = 'nullable';
|
||||
}
|
||||
|
||||
// 타입별 규칙 추가
|
||||
$type = $config['type'] ?? 'string';
|
||||
|
||||
switch ($type) {
|
||||
case 'string':
|
||||
$fieldRules[] = 'string';
|
||||
if (isset($config['max'])) {
|
||||
$fieldRules[] = 'max:'.$config['max'];
|
||||
}
|
||||
if (isset($config['min'])) {
|
||||
$fieldRules[] = 'min:'.$config['min'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'integer':
|
||||
$fieldRules[] = 'integer';
|
||||
if (isset($config['min'])) {
|
||||
$fieldRules[] = 'min:'.$config['min'];
|
||||
}
|
||||
if (isset($config['max'])) {
|
||||
$fieldRules[] = 'max:'.$config['max'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'boolean':
|
||||
$fieldRules[] = 'boolean';
|
||||
break;
|
||||
|
||||
case 'enum':
|
||||
$options = $config['options'] ?? [];
|
||||
if (! empty($options)) {
|
||||
$fieldRules[] = 'in:'.implode(',', $options);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'url':
|
||||
$fieldRules[] = 'url';
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
$fieldRules[] = 'email';
|
||||
break;
|
||||
|
||||
case 'array':
|
||||
$fieldRules[] = 'array';
|
||||
break;
|
||||
}
|
||||
|
||||
$rules[$field] = $fieldRules;
|
||||
}
|
||||
|
||||
return HookManager::applyFilters('core.plugin_settings.update_rules', $rules, $identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 에러 메시지를 반환합니다.
|
||||
*
|
||||
* @return array 에러 메시지 배열
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'required' => __('validation.required'),
|
||||
'string' => __('validation.string'),
|
||||
'integer' => __('validation.integer'),
|
||||
'boolean' => __('validation.boolean'),
|
||||
'in' => __('validation.in'),
|
||||
'url' => __('validation.url'),
|
||||
'email' => __('validation.email'),
|
||||
'array' => __('validation.array'),
|
||||
'max' => __('validation.max'),
|
||||
'min' => __('validation.min'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Attachment;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Attachment;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 첨부파일 순서 변경 요청 검증
|
||||
*/
|
||||
class ReorderAttachmentsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한 확인
|
||||
*
|
||||
* @return bool 항상 true
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 규칙
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'order' => ['required', 'array', 'min:1'],
|
||||
'order.*.id' => ['required', 'integer', Rule::exists(Attachment::class, 'id')],
|
||||
'order.*.order' => ['required', 'integer', 'min:0'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.attachment.reorder_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 메시지
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'order.required' => __('attachment.validation.order_required'),
|
||||
'order.array' => __('attachment.validation.order_array'),
|
||||
'order.*.id.required' => __('attachment.validation.order_id_required'),
|
||||
'order.*.id.exists' => __('attachment.validation.order_id_exists'),
|
||||
'order.*.order.required' => __('attachment.validation.order_value_required'),
|
||||
'order.*.order.integer' => __('attachment.validation.order_value_integer'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Attachment;
|
||||
|
||||
use App\Enums\AttachmentSourceType;
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 첨부파일 업로드 요청 검증
|
||||
*/
|
||||
class UploadAttachmentRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한 확인
|
||||
*
|
||||
* @return bool 항상 true
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 규칙
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$maxSize = config('attachment.max_size', 10) * 1024; // MB to KB
|
||||
|
||||
$rules = [
|
||||
'file' => ['required', 'file', 'max:' . $maxSize],
|
||||
'attachmentable_type' => ['nullable', 'string', 'max:255'],
|
||||
'attachmentable_id' => ['nullable', 'integer', 'min:1'],
|
||||
'collection' => ['sometimes', 'string', 'max:100'],
|
||||
'source_type' => ['sometimes', Rule::enum(AttachmentSourceType::class)],
|
||||
'source_identifier' => ['nullable', 'string', 'max:255'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.attachment.upload_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 메시지
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'file.required' => __('attachment.validation.file_required'),
|
||||
'file.file' => __('attachment.validation.file_invalid'),
|
||||
'file.max' => __('attachment.validation.file_max', ['max' => config('attachment.max_size', 10)]),
|
||||
'attachmentable_type.string' => __('attachment.validation.type_invalid'),
|
||||
'attachmentable_id.integer' => __('attachment.validation.id_invalid'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 준비
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'collection' => $this->collection ?? 'default',
|
||||
'source_type' => $this->source_type ?? AttachmentSourceType::Core->value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Attachment;
|
||||
|
||||
use App\Enums\AttachmentSourceType;
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 첨부파일 일괄 업로드 요청 검증
|
||||
*/
|
||||
class UploadBatchAttachmentRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한 확인
|
||||
*
|
||||
* @return bool 항상 true
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 규칙
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$maxSize = config('attachment.max_size', 10) * 1024; // MB to KB
|
||||
|
||||
$rules = [
|
||||
'files' => ['required', 'array', 'min:1'],
|
||||
'files.*' => ['file', 'max:' . $maxSize],
|
||||
'attachmentable_type' => ['nullable', 'string', 'max:255'],
|
||||
'attachmentable_id' => ['nullable', 'integer', 'min:1'],
|
||||
'collection' => ['sometimes', 'string', 'max:100'],
|
||||
'source_type' => ['sometimes', Rule::enum(AttachmentSourceType::class)],
|
||||
'source_identifier' => ['nullable', 'string', 'max:255'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.attachment.upload_batch_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 메시지
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'files.required' => __('attachment.validation.files_required'),
|
||||
'files.array' => __('attachment.validation.files_array'),
|
||||
'files.min' => __('attachment.validation.files_min'),
|
||||
'files.*.file' => __('attachment.validation.file_invalid'),
|
||||
'files.*.max' => __('attachment.validation.file_max', ['max' => config('attachment.max_size', 10)]),
|
||||
'attachmentable_type.string' => __('attachment.validation.type_invalid'),
|
||||
'attachmentable_id.integer' => __('attachment.validation.id_invalid'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 준비
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'collection' => $this->collection ?? 'default',
|
||||
'source_type' => $this->source_type ?? AttachmentSourceType::Core->value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ForgotPasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'email' => ['required', 'email', Rule::exists(User::class, 'email')],
|
||||
'redirect_prefix' => ['nullable', 'string', 'in:admin'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.auth.forgot_password_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'email.required' => __('validation.auth.email.required'),
|
||||
'email.email' => __('validation.auth.email.email'),
|
||||
'email.exists' => __('validation.auth.email.exists'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|string|min:6',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.auth.login_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'email.required' => __('validation.auth.email.required'),
|
||||
'email.email' => __('validation.auth.email.email'),
|
||||
'password.required' => __('validation.auth.password.required'),
|
||||
'password.min' => __('validation.auth.password.min'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RegisterRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:255',
|
||||
'nickname' => 'nullable|string|max:50',
|
||||
'email' => ['required', 'string', 'email', 'max:255', Rule::unique(User::class)],
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
'language' => 'nullable|string|in:' . implode(',', config('app.supported_locales', ['ko', 'en'])),
|
||||
'agree_terms' => 'accepted',
|
||||
'agree_privacy' => 'accepted',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.auth.register_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => __('validation.auth.name.required'),
|
||||
'name.max' => __('validation.auth.name.max'),
|
||||
'nickname.max' => __('validation.auth.nickname.max'),
|
||||
'email.required' => __('validation.auth.email.required'),
|
||||
'email.email' => __('validation.auth.email.email'),
|
||||
'email.unique' => __('validation.auth.email.unique'),
|
||||
'password.required' => __('validation.auth.password.required'),
|
||||
'password.min' => __('validation.auth.password.min'),
|
||||
'password.confirmed' => __('validation.auth.password.confirmed'),
|
||||
'agree_terms.accepted' => __('validation.auth.agree_terms.accepted'),
|
||||
'agree_privacy.accepted' => __('validation.auth.agree_privacy.accepted'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ResetPasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'token' => 'required|string',
|
||||
'email' => ['required', 'email', Rule::exists(User::class, 'email')],
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.auth.reset_password_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'token.required' => __('validation.auth.token.required'),
|
||||
'email.required' => __('validation.auth.email.required'),
|
||||
'email.email' => __('validation.auth.email.email'),
|
||||
'email.exists' => __('validation.auth.email.exists'),
|
||||
'password.required' => __('validation.auth.password.required'),
|
||||
'password.min' => __('validation.auth.password.min'),
|
||||
'password.confirmed' => __('validation.auth.password.confirmed'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 비밀번호 재설정 토큰 검증 요청
|
||||
*/
|
||||
class ValidateResetTokenRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true; // 공개 엔드포인트
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'token' => 'required|string',
|
||||
'email' => 'required|email',
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.auth.validate_reset_token_rules',
|
||||
$rules,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
$messages = [
|
||||
'token.required' => __('validation.auth.token.required'),
|
||||
'token.string' => __('validation.string', ['attribute' => __('validation.attributes.token')]),
|
||||
'email.required' => __('validation.auth.email.required'),
|
||||
'email.email' => __('validation.auth.email.email'),
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.auth.validate_reset_token_messages',
|
||||
$messages,
|
||||
$this
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class VerifyPasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'password' => 'required|string',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.auth.verify_password_rules', $rules);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Extension;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 확장 Changelog 조회 요청
|
||||
*
|
||||
* 모듈/플러그인/템플릿 공통으로 사용합니다.
|
||||
*/
|
||||
class ChangelogRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'source' => 'nullable|string|in:active,bundled,github',
|
||||
'from_version' => 'nullable|string|regex:/^\d+\.\d+\.\d+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$/',
|
||||
'to_version' => 'nullable|string|regex:/^\d+\.\d+\.\d+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$/|required_with:from_version',
|
||||
];
|
||||
|
||||
return HookManager::applyFilters('core.extension.changelog_rules', $rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 에러 메시지를 정의합니다.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'source.in' => __('common.changelog_validation.source_in'),
|
||||
'from_version.regex' => __('common.changelog_validation.version_format', ['attribute' => __('validation.attributes.from_version')]),
|
||||
'to_version.regex' => __('common.changelog_validation.version_format', ['attribute' => __('validation.attributes.to_version')]),
|
||||
'to_version.required_with' => __('common.changelog_validation.to_version_required'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Layout;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 레이아웃 조회 요청 검증
|
||||
*
|
||||
* 레이아웃 조회 권한을 확인합니다.
|
||||
* 조회 시에는 데이터 검증이 필요하지 않으며, 권한 체크만 수행합니다.
|
||||
*/
|
||||
class GetLayoutRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// 조회 요청은 특별한 검증 규칙이 필요하지 않음
|
||||
// 라우트 파라미터 검증은 컨트롤러에서 처리
|
||||
$rules = [];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.layout.get_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
$messages = [];
|
||||
|
||||
// 모듈/플러그인이 validation messages를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.layout.get_validation_messages', $messages, $this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Layout;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Template;
|
||||
use App\Rules\ValidDataSourceMerge;
|
||||
use App\Rules\ValidParentLayout;
|
||||
use App\Rules\ValidSlotStructure;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreLayoutInheritanceRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
// 기본 필드
|
||||
'template_id' => ['required', 'integer', Rule::exists(Template::class, 'id')],
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
|
||||
// 레이아웃 content
|
||||
'content' => ['required', 'array'],
|
||||
'content.version' => ['required', 'string'],
|
||||
'content.layout_name' => ['required', 'string'],
|
||||
|
||||
// 레이아웃 상속 관련 검증
|
||||
'content.extends' => ['nullable', 'string', new ValidParentLayout],
|
||||
'content.slots' => ['nullable', 'array', new ValidSlotStructure],
|
||||
'content.data_sources' => ['nullable', 'array', new ValidDataSourceMerge],
|
||||
|
||||
// 메타 정보 (선택)
|
||||
'content.meta' => ['sometimes', 'array'],
|
||||
'content.meta.title' => ['sometimes', 'string'],
|
||||
'content.meta.description' => ['sometimes', 'string'],
|
||||
|
||||
// 컴포넌트 (선택, extends 사용 시 없을 수 있음)
|
||||
'content.components' => ['sometimes', 'array'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.layout.store_inheritance_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'template_id.required' => __('validation.request.template_id.required'),
|
||||
'template_id.integer' => __('validation.request.template_id.integer'),
|
||||
'template_id.exists' => __('validation.request.template_id.exists'),
|
||||
|
||||
'name.required' => __('validation.request.layout_name.required'),
|
||||
'name.string' => __('validation.request.layout_name.string'),
|
||||
'name.max' => __('validation.request.layout_name.max', ['max' => 255]),
|
||||
|
||||
'content.required' => __('validation.request.content.required'),
|
||||
'content.array' => __('validation.request.content.array'),
|
||||
|
||||
'content.version.required' => __('validation.layout.required_field_missing', ['field' => 'version']),
|
||||
'content.version.string' => __('validation.layout.version_must_be_string'),
|
||||
|
||||
'content.layout_name.required' => __('validation.layout.required_field_missing', ['field' => 'layout_name']),
|
||||
'content.layout_name.string' => __('validation.layout.layout_name_must_be_string'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Layout;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 레이아웃 미리보기 생성 요청 검증
|
||||
*
|
||||
* 편집 중인 레이아웃 content를 임시 저장하여 미리보기를 생성합니다.
|
||||
*/
|
||||
class StoreLayoutPreviewRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 전처리
|
||||
*
|
||||
* content가 JSON 문자열로 전송된 경우 배열로 변환합니다.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$content = $this->input('content');
|
||||
|
||||
if (is_string($content)) {
|
||||
$decoded = json_decode($content, true);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
|
||||
$this->merge(['content' => $decoded]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'content' => ['required', 'array'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'content.required' => __('validation.layout.content.required'),
|
||||
'content.array' => __('validation.layout.content.array'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Layout;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Template;
|
||||
use App\Models\TemplateLayout;
|
||||
use App\Rules\ComponentExists;
|
||||
use App\Rules\NoExternalUrls;
|
||||
use App\Rules\ValidLayoutStructure;
|
||||
use App\Rules\WhitelistedEndpoint;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 레이아웃 생성 요청 검증
|
||||
*
|
||||
* Custom Rules를 조합하여 악의적 레이아웃 JSON을 차단합니다.
|
||||
* Controller 진입 전 자동으로 검증이 수행됩니다.
|
||||
*/
|
||||
class StoreLayoutRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
// 템플릿 ID (필수)
|
||||
'template_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::exists(Template::class, 'id'),
|
||||
],
|
||||
|
||||
// 레이아웃 이름 (필수)
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
// 같은 템플릿 내에서 레이아웃 이름 중복 방지
|
||||
Rule::unique(TemplateLayout::class, 'name')
|
||||
->where('template_id', $this->input('template_id')),
|
||||
],
|
||||
|
||||
// 레이아웃 JSON 내용 (필수)
|
||||
'content' => [
|
||||
'required',
|
||||
'array',
|
||||
// 1. JSON 스키마 검증
|
||||
new ValidLayoutStructure,
|
||||
// 2. 컴포넌트 존재 여부 검증
|
||||
new ComponentExists,
|
||||
// 3. API endpoint 화이트리스트 검증
|
||||
new WhitelistedEndpoint,
|
||||
// 4. 외부 URL 차단
|
||||
new NoExternalUrls,
|
||||
],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.layout.store_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
// 템플릿 ID 검증 메시지
|
||||
'template_id.required' => __('validation.request.template_id.required'),
|
||||
'template_id.integer' => __('validation.request.template_id.integer'),
|
||||
'template_id.exists' => __('validation.request.template_id.exists'),
|
||||
|
||||
// 레이아웃 이름 검증 메시지
|
||||
'name.required' => __('validation.request.layout_name.required'),
|
||||
'name.string' => __('validation.request.layout_name.string'),
|
||||
'name.max' => __('validation.request.layout_name.max', ['max' => 255]),
|
||||
'name.unique' => __('validation.request.layout_name.unique'),
|
||||
|
||||
// 레이아웃 JSON 검증 메시지
|
||||
'content.required' => __('validation.request.content.required'),
|
||||
'content.array' => __('validation.request.content.array'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Layout;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Rules\NoExternalUrls;
|
||||
use App\Rules\ValidDataSourceMerge;
|
||||
use App\Rules\ValidLayoutStructure;
|
||||
use App\Rules\ValidParentLayout;
|
||||
use App\Rules\ValidPermissionStructure;
|
||||
use App\Rules\ValidSlotStructure;
|
||||
use App\Rules\WhitelistedEndpoint;
|
||||
use Closure;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 레이아웃 Content 업데이트 요청 검증
|
||||
*
|
||||
* 레이아웃의 content JSON 구조를 검증합니다.
|
||||
* Custom Rule을 통해 레이아웃 구조, 엔드포인트, 슬롯, 데이터소스 병합을 검증합니다.
|
||||
*/
|
||||
class UpdateLayoutContentRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 전처리
|
||||
*
|
||||
* content가 JSON 문자열로 전송된 경우 배열로 변환합니다.
|
||||
* 프론트엔드에서 CodeEditor의 값을 그대로 전송할 수 있으므로
|
||||
* 문자열/배열 모두 처리할 수 있도록 합니다.
|
||||
*
|
||||
* 또한, ValidParentLayout 규칙에서 template_id를 사용하므로
|
||||
* 라우트 파라미터에서 templateName을 가져와 template_id로 변환합니다.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$content = $this->input('content');
|
||||
|
||||
// content가 JSON 문자열인 경우 배열로 변환
|
||||
if (is_string($content)) {
|
||||
$decoded = json_decode($content, true);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
|
||||
$this->merge(['content' => $decoded]);
|
||||
}
|
||||
// JSON 파싱 실패 시 원본 유지 (검증에서 'array' 규칙으로 실패 처리)
|
||||
}
|
||||
|
||||
// 라우트 파라미터에서 templateName을 가져와 template_id로 변환
|
||||
// ValidParentLayout 규칙에서 template_id를 사용하기 때문에 필요
|
||||
$templateName = $this->route('templateName');
|
||||
if ($templateName && ! $this->has('template_id')) {
|
||||
$template = \App\Models\Template::where('identifier', $templateName)->first();
|
||||
if ($template) {
|
||||
$this->merge(['template_id' => $template->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* extends 레이아웃과 standalone 레이아웃의 구조 차이를 고려합니다:
|
||||
* - standalone: endpoint, components 필수
|
||||
* - extends: extends, slots 사용 (endpoint, components는 부모에서 상속)
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$content = $this->input('content');
|
||||
|
||||
// extends 레이아웃 여부 (extends 필드가 있고 null이 아닌 경우)
|
||||
$isExtending = is_array($content) && isset($content['extends']) && $content['extends'] !== null;
|
||||
|
||||
// Base 레이아웃 여부 (slots를 정의하고 있는 경우 - 다른 레이아웃이 상속받는 용도)
|
||||
$isBaseLayout = is_array($content) && isset($content['slots']) && is_array($content['slots']);
|
||||
|
||||
$rules = [
|
||||
// content 전체 검증 (ValidLayoutStructure에서 extends/standalone 분기 처리)
|
||||
'content' => [
|
||||
'required',
|
||||
'array',
|
||||
new ValidLayoutStructure,
|
||||
],
|
||||
|
||||
// 버전 필드
|
||||
'content.version' => ['required', 'string'],
|
||||
|
||||
// 레이아웃명
|
||||
'content.layout_name' => ['required', 'string', 'max:255'],
|
||||
|
||||
// 상속 검증 (extends가 있는 경우)
|
||||
'content.extends' => [
|
||||
'nullable',
|
||||
'string',
|
||||
function (string $attribute, mixed $value, Closure $fail) {
|
||||
if ($value === null) {
|
||||
return;
|
||||
}
|
||||
$layoutId = request()->route('id');
|
||||
$validator = new ValidParentLayout($layoutId);
|
||||
$validator->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
|
||||
// 슬롯 검증 (extends 레이아웃에서 사용)
|
||||
'content.slots' => [
|
||||
'nullable',
|
||||
'array',
|
||||
new ValidSlotStructure,
|
||||
],
|
||||
|
||||
// 데이터소스 검증
|
||||
'content.data_sources' => [
|
||||
'nullable',
|
||||
'array',
|
||||
new ValidDataSourceMerge,
|
||||
],
|
||||
|
||||
// 메타데이터 (legacy - metadata 키 사용하는 경우)
|
||||
'content.metadata' => ['nullable', 'array'],
|
||||
|
||||
// 메타 정보 (title, description, auth_required 등)
|
||||
'content.meta' => ['nullable', 'array'],
|
||||
'content.meta.title' => ['nullable', 'string'],
|
||||
'content.meta.description' => ['nullable', 'string'],
|
||||
'content.meta.auth_required' => ['nullable', 'boolean'],
|
||||
'content.meta.is_base' => ['nullable', 'boolean'],
|
||||
|
||||
// SEO 메타데이터
|
||||
'content.meta.seo' => ['nullable', 'array'],
|
||||
'content.meta.seo.enabled' => ['nullable', 'boolean'],
|
||||
'content.meta.seo.data_sources' => ['nullable', 'array'],
|
||||
'content.meta.seo.data_sources.*' => ['string'],
|
||||
'content.meta.seo.priority' => ['nullable', 'numeric', 'min:0', 'max:1'],
|
||||
'content.meta.seo.changefreq' => ['nullable', 'string', 'in:always,hourly,daily,weekly,monthly,yearly,never'],
|
||||
'content.meta.seo.og' => ['nullable', 'array'],
|
||||
'content.meta.seo.structured_data' => ['nullable', 'array'],
|
||||
|
||||
// 모달 컴포넌트 정의
|
||||
'content.modals' => ['nullable', 'array'],
|
||||
|
||||
// 상태 정의 (레이아웃 레벨 초기 상태)
|
||||
'content.state' => ['nullable', 'array'],
|
||||
|
||||
// 초기화 액션 (레이아웃 로드 시 실행)
|
||||
'content.init_actions' => ['nullable', 'array'],
|
||||
|
||||
// 정의 (재사용 가능한 컴포넌트 조각)
|
||||
'content.defines' => ['nullable', 'array'],
|
||||
|
||||
// 초기 상태 (init_state - state의 대체 키)
|
||||
'content.init_state' => ['nullable', 'array'],
|
||||
|
||||
// 라우트 정의
|
||||
'content.routes' => ['nullable', 'array'],
|
||||
|
||||
// 계산된 속성
|
||||
'content.computed' => ['nullable', 'array'],
|
||||
|
||||
// Named Actions (재사용 가능한 액션 정의)
|
||||
'content.named_actions' => ['nullable', 'array'],
|
||||
'content.named_actions.*' => ['array'],
|
||||
|
||||
// 권한 (레이아웃 접근에 필요한 권한 식별자 배열 또는 OR/AND 구조)
|
||||
'content.permissions' => ['nullable', new ValidPermissionStructure],
|
||||
|
||||
// 전역 헤더 (API 호출 시 자동 적용되는 HTTP 헤더)
|
||||
'content.globalHeaders' => ['nullable', 'array'],
|
||||
'content.globalHeaders.*.pattern' => ['required', 'string'],
|
||||
'content.globalHeaders.*.headers' => ['required', 'array'],
|
||||
'content.globalHeaders.*.headers.*' => ['string'],
|
||||
|
||||
// 전환 오버레이 설정 (페이지 전환 시 stale DOM 방지)
|
||||
'content.transition_overlay' => ['nullable'],
|
||||
'content.transition_overlay.enabled' => ['nullable', 'boolean'],
|
||||
'content.transition_overlay.style' => ['nullable', 'string', Rule::in(['opaque', 'blur', 'fade', 'skeleton', 'spinner'])],
|
||||
'content.transition_overlay.target' => ['nullable', 'string', 'max:100'],
|
||||
'content.transition_overlay.fallback_target' => ['nullable', 'string', 'max:100'],
|
||||
'content.transition_overlay.skeleton' => ['nullable', 'array'],
|
||||
'content.transition_overlay.skeleton.component' => ['nullable', 'required_with:content.transition_overlay.skeleton', 'string', 'max:100'],
|
||||
'content.transition_overlay.skeleton.animation' => ['nullable', 'string', Rule::in(['pulse', 'wave', 'none'])],
|
||||
'content.transition_overlay.skeleton.iteration_count' => ['nullable', 'integer', 'min:1', 'max:50'],
|
||||
'content.transition_overlay.spinner' => ['nullable', 'array'],
|
||||
'content.transition_overlay.spinner.component' => ['nullable', 'string', 'max:100'],
|
||||
'content.transition_overlay.spinner.text' => ['nullable', 'string', 'max:200'],
|
||||
];
|
||||
|
||||
// extends 레이아웃 또는 Base 레이아웃이 아닌 경우에만 endpoint, components 필수
|
||||
// - extends 레이아웃: 부모로부터 endpoint 상속
|
||||
// - Base 레이아웃 (slots 정의): 자식 레이아웃이 endpoint 정의
|
||||
if (! $isExtending && ! $isBaseLayout) {
|
||||
$rules['content.endpoint'] = [
|
||||
'required',
|
||||
'string',
|
||||
new WhitelistedEndpoint,
|
||||
new NoExternalUrls,
|
||||
];
|
||||
$rules['content.components'] = ['required', 'array'];
|
||||
} else {
|
||||
// extends 또는 Base 레이아웃은 endpoint가 선택적
|
||||
$rules['content.endpoint'] = [
|
||||
'nullable',
|
||||
'string',
|
||||
new WhitelistedEndpoint,
|
||||
new NoExternalUrls,
|
||||
];
|
||||
// extends 레이아웃은 components 또는 slots 중 하나 사용
|
||||
// ValidLayoutStructure에서 상세 검증
|
||||
$rules['content.components'] = ['nullable', 'array'];
|
||||
}
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.layout.update_content_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'content.required' => __('validation.layout.content.required'),
|
||||
'content.array' => __('validation.layout.content.array'),
|
||||
'content.version.required' => __('validation.layout.version.required'),
|
||||
'content.version.string' => __('validation.layout.version.string'),
|
||||
'content.layout_name.required' => __('validation.layout.layout_name.required'),
|
||||
'content.layout_name.string' => __('validation.layout.layout_name.string'),
|
||||
'content.layout_name.max' => __('validation.layout.layout_name.max'),
|
||||
'content.endpoint.required' => __('validation.layout.endpoint.required'),
|
||||
'content.endpoint.string' => __('validation.layout.endpoint.string'),
|
||||
'content.extends.string' => __('validation.layout.extends.string'),
|
||||
'content.slots.array' => __('validation.layout.slots.array'),
|
||||
'content.data_sources.array' => __('validation.layout.data_sources.array'),
|
||||
'content.components.required' => __('validation.layout.components.required'),
|
||||
'content.components.array' => __('validation.layout.components.array'),
|
||||
'content.metadata.array' => __('validation.layout.metadata.array'),
|
||||
'content.meta.array' => __('validation.layout.meta.array'),
|
||||
'content.meta.title.string' => __('validation.layout.meta.title.string'),
|
||||
'content.meta.description.string' => __('validation.layout.meta.description.string'),
|
||||
'content.meta.auth_required.boolean' => __('validation.layout.meta.auth_required.boolean'),
|
||||
'content.meta.is_base.boolean' => __('validation.layout.meta.is_base.boolean'),
|
||||
'content.meta.seo.array' => __('validation.layout.meta.seo.array'),
|
||||
'content.meta.seo.enabled.boolean' => __('validation.layout.meta.seo.enabled.boolean'),
|
||||
'content.meta.seo.data_sources.array' => __('validation.layout.meta.seo.data_sources.array'),
|
||||
'content.meta.seo.data_sources.*.string' => __('validation.layout.meta.seo.data_sources.string'),
|
||||
'content.meta.seo.priority.numeric' => __('validation.layout.meta.seo.priority.numeric'),
|
||||
'content.meta.seo.priority.min' => __('validation.layout.meta.seo.priority.min'),
|
||||
'content.meta.seo.priority.max' => __('validation.layout.meta.seo.priority.max'),
|
||||
'content.meta.seo.changefreq.string' => __('validation.layout.meta.seo.changefreq.string'),
|
||||
'content.meta.seo.changefreq.in' => __('validation.layout.meta.seo.changefreq.in'),
|
||||
'content.meta.seo.og.array' => __('validation.layout.meta.seo.og.array'),
|
||||
'content.meta.seo.structured_data.array' => __('validation.layout.meta.seo.structured_data.array'),
|
||||
'content.modals.array' => __('validation.layout.modals.array'),
|
||||
'content.state.array' => __('validation.layout.state.array'),
|
||||
'content.init_actions.array' => __('validation.layout.init_actions.array'),
|
||||
'content.defines.array' => __('validation.layout.defines.array'),
|
||||
'content.init_state.array' => __('validation.layout.init_state.array'),
|
||||
'content.routes.array' => __('validation.layout.routes.array'),
|
||||
'content.computed.array' => __('validation.layout.computed.array'),
|
||||
'content.permissions' => __('validation.layout.permissions.array'),
|
||||
'content.globalHeaders.array' => __('validation.layout.globalHeaders.array'),
|
||||
'content.globalHeaders.*.pattern.required' => __('validation.layout.globalHeaders.pattern.required'),
|
||||
'content.globalHeaders.*.pattern.string' => __('validation.layout.globalHeaders.pattern.string'),
|
||||
'content.globalHeaders.*.headers.required' => __('validation.layout.globalHeaders.headers.required'),
|
||||
'content.globalHeaders.*.headers.array' => __('validation.layout.globalHeaders.headers.array'),
|
||||
'content.globalHeaders.*.headers.*.string' => __('validation.layout.globalHeaders.headers.string'),
|
||||
|
||||
// transition_overlay
|
||||
'content.transition_overlay.enabled.boolean' => __('validation.layout.transition_overlay.enabled.boolean'),
|
||||
'content.transition_overlay.style.string' => __('validation.layout.transition_overlay.style.string'),
|
||||
'content.transition_overlay.style.in' => __('validation.layout.transition_overlay.style.in'),
|
||||
'content.transition_overlay.target.string' => __('validation.layout.transition_overlay.target.string'),
|
||||
'content.transition_overlay.target.max' => __('validation.layout.transition_overlay.target.max'),
|
||||
'content.transition_overlay.fallback_target.string' => __('validation.layout.transition_overlay.fallback_target.string'),
|
||||
'content.transition_overlay.fallback_target.max' => __('validation.layout.transition_overlay.fallback_target.max'),
|
||||
'content.transition_overlay.skeleton.array' => __('validation.layout.transition_overlay.skeleton.array'),
|
||||
'content.transition_overlay.skeleton.component.string' => __('validation.layout.transition_overlay.skeleton.component.string'),
|
||||
'content.transition_overlay.skeleton.component.max' => __('validation.layout.transition_overlay.skeleton.component.max'),
|
||||
'content.transition_overlay.skeleton.animation.string' => __('validation.layout.transition_overlay.skeleton.animation.string'),
|
||||
'content.transition_overlay.skeleton.animation.in' => __('validation.layout.transition_overlay.skeleton.animation.in'),
|
||||
'content.transition_overlay.skeleton.iteration_count.integer' => __('validation.layout.transition_overlay.skeleton.iteration_count.integer'),
|
||||
'content.transition_overlay.skeleton.iteration_count.min' => __('validation.layout.transition_overlay.skeleton.iteration_count.min'),
|
||||
'content.transition_overlay.skeleton.iteration_count.max' => __('validation.layout.transition_overlay.skeleton.iteration_count.max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Layout;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Template;
|
||||
use App\Rules\ValidDataSourceMerge;
|
||||
use App\Rules\ValidParentLayout;
|
||||
use App\Rules\ValidSlotStructure;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateLayoutInheritanceRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// 현재 레이아웃의 template_id를 요청 데이터에 추가 (Custom Rule에서 사용)
|
||||
$layout = $this->route('layout');
|
||||
if ($layout) {
|
||||
$this->merge(['template_id' => $layout->template_id]);
|
||||
}
|
||||
|
||||
$rules = [
|
||||
// template_id는 라우트에서 가져온 레이아웃의 template_id 사용
|
||||
'template_id' => ['sometimes', 'integer', Rule::exists(Template::class, 'id')],
|
||||
|
||||
// name 필드는 선택 (업데이트 시 변경 가능)
|
||||
'name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
// 레이아웃 content
|
||||
'content' => ['required', 'array'],
|
||||
'content.version' => ['required', 'string'],
|
||||
'content.layout_name' => ['required', 'string'],
|
||||
|
||||
// 레이아웃 상속 관련 검증
|
||||
'content.extends' => ['nullable', 'string', new ValidParentLayout],
|
||||
'content.slots' => ['nullable', 'array', new ValidSlotStructure],
|
||||
'content.data_sources' => ['nullable', 'array', new ValidDataSourceMerge],
|
||||
|
||||
// 메타 정보 (선택)
|
||||
'content.meta' => ['sometimes', 'array'],
|
||||
'content.meta.title' => ['sometimes', 'string'],
|
||||
'content.meta.description' => ['sometimes', 'string'],
|
||||
|
||||
// 컴포넌트 (선택, extends 사용 시 없을 수 있음)
|
||||
'content.components' => ['sometimes', 'array'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.layout.update_inheritance_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'template_id.integer' => __('validation.request.template_id.integer'),
|
||||
'template_id.exists' => __('validation.request.template_id.exists'),
|
||||
|
||||
'name.string' => __('validation.request.layout_name.string'),
|
||||
'name.max' => __('validation.request.layout_name.max', ['max' => 255]),
|
||||
|
||||
'content.required' => __('validation.request.content.required'),
|
||||
'content.array' => __('validation.request.content.array'),
|
||||
|
||||
'content.version.required' => __('validation.layout.required_field_missing', ['field' => 'version']),
|
||||
'content.version.string' => __('validation.layout.version_must_be_string'),
|
||||
|
||||
'content.layout_name.required' => __('validation.layout.required_field_missing', ['field' => 'layout_name']),
|
||||
'content.layout_name.string' => __('validation.layout.layout_name_must_be_string'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Layout;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Template;
|
||||
use App\Models\TemplateLayout;
|
||||
use App\Rules\ComponentExists;
|
||||
use App\Rules\NoExternalUrls;
|
||||
use App\Rules\ValidLayoutStructure;
|
||||
use App\Rules\WhitelistedEndpoint;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 레이아웃 수정 요청 검증
|
||||
*
|
||||
* Custom Rules를 조합하여 악의적 레이아웃 JSON을 차단합니다.
|
||||
* 부분 업데이트를 허용하며, Controller 진입 전 자동으로 검증이 수행됩니다.
|
||||
*/
|
||||
class UpdateLayoutRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// 현재 레이아웃 ID (라우트 파라미터에서 가져옴)
|
||||
$layoutId = $this->route('id');
|
||||
|
||||
$rules = [
|
||||
// 템플릿 ID (선택적)
|
||||
'template_id' => [
|
||||
'sometimes',
|
||||
'integer',
|
||||
Rule::exists(Template::class, 'id'),
|
||||
],
|
||||
|
||||
// 레이아웃 이름 (선택적)
|
||||
'name' => [
|
||||
'sometimes',
|
||||
'string',
|
||||
'max:255',
|
||||
// 같은 템플릿 내에서 레이아웃 이름 중복 방지 (자기 자신 제외)
|
||||
Rule::unique(TemplateLayout::class, 'name')
|
||||
->ignore($layoutId)
|
||||
->where('template_id', $this->input('template_id', 'NULL')),
|
||||
],
|
||||
|
||||
// 레이아웃 JSON 내용 (선택적)
|
||||
'content' => [
|
||||
'sometimes',
|
||||
'array',
|
||||
// 1. JSON 스키마 검증
|
||||
new ValidLayoutStructure,
|
||||
// 2. 컴포넌트 존재 여부 검증
|
||||
new ComponentExists,
|
||||
// 3. API endpoint 화이트리스트 검증
|
||||
new WhitelistedEndpoint,
|
||||
// 4. 외부 URL 차단
|
||||
new NoExternalUrls,
|
||||
],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.layout.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
// 템플릿 ID 검증 메시지
|
||||
'template_id.integer' => __('validation.request.template_id.integer'),
|
||||
'template_id.exists' => __('validation.request.template_id.exists'),
|
||||
|
||||
// 레이아웃 이름 검증 메시지
|
||||
'name.string' => __('validation.request.layout_name.string'),
|
||||
'name.max' => __('validation.request.layout_name.max', ['max' => 255]),
|
||||
'name.unique' => __('validation.request.layout_name.unique'),
|
||||
|
||||
// 레이아웃 JSON 검증 메시지
|
||||
'content.array' => __('validation.request.content.array'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\MailSendLog;
|
||||
|
||||
use App\Models\MailSendLog;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 메일 발송 이력 일괄 삭제 요청을 검증합니다.
|
||||
*/
|
||||
class MailSendLogBulkDeleteRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 항상 true (권한은 permission 미들웨어에서 처리)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 유효성 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'ids' => ['required', 'array', 'min:1'],
|
||||
'ids.*' => ['required', 'integer', Rule::exists(MailSendLog::class, 'id')],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 사용자 정의 유효성 검증 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string> 메시지
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'ids.required' => __('mail_send_log.validation.ids_required'),
|
||||
'ids.min' => __('mail_send_log.validation.ids_min'),
|
||||
'ids.*.exists' => __('mail_send_log.validation.id_not_found'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\MailSendLog;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 메일 발송 이력 삭제 요청을 검증합니다.
|
||||
*/
|
||||
class MailSendLogDeleteRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 항상 true (권한은 permission 미들웨어에서 처리)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 유효성 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\MailSendLog;
|
||||
|
||||
use App\Enums\ExtensionOwnerType;
|
||||
use App\Enums\MailSendStatus;
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 메일 발송 이력 목록 조회 요청을 검증합니다.
|
||||
*/
|
||||
class MailSendLogIndexRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 항상 true (권한은 permission 미들웨어에서 처리)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 유효성 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'extension_type' => ['nullable', 'array'],
|
||||
'extension_type.*' => ['string', Rule::in(ExtensionOwnerType::values())],
|
||||
'extension_identifier' => ['nullable', 'array'],
|
||||
'extension_identifier.*' => ['string', 'max:100'],
|
||||
'template_type' => ['nullable', 'string', 'max:100'],
|
||||
'status' => ['nullable', 'array'],
|
||||
'status.*' => ['string', Rule::in(array_column(MailSendStatus::cases(), 'value'))],
|
||||
'search' => ['nullable', 'string', 'max:255'],
|
||||
'search_type' => ['nullable', 'string', Rule::in(['all', 'recipient_email', 'recipient_name', 'subject'])],
|
||||
'date_from' => ['nullable', 'date'],
|
||||
'date_to' => ['nullable', 'date', 'after_or_equal:date_from'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||
'sort_by' => ['nullable', 'string', Rule::in(['sent_at', 'recipient_email', 'subject', 'extension_type', 'status'])],
|
||||
'sort_order' => ['nullable', 'string', Rule::in(['asc', 'desc'])],
|
||||
];
|
||||
|
||||
return HookManager::applyFilters('core.mail_send_log.index_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 사용자 정의 유효성 검증 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string> 메시지
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'status.in' => __('mail_send_log.validation.status_invalid'),
|
||||
'date_to.after_or_equal' => __('mail_send_log.validation.date_range_invalid'),
|
||||
'per_page.min' => __('mail_send_log.validation.per_page_min'),
|
||||
'per_page.max' => __('mail_send_log.validation.per_page_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\MailTemplate;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 메일 템플릿 목록 조회 요청을 검증합니다.
|
||||
*/
|
||||
class MailTemplateIndexRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 항상 true (권한은 permission 미들웨어에서 처리)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 유효성 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'search' => ['nullable', 'string', 'max:255'],
|
||||
'search_type' => ['nullable', 'string', Rule::in(['all', 'subject', 'body'])],
|
||||
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||
'sort_by' => ['nullable', 'string', Rule::in(['id', 'type', 'is_active', 'created_at', 'updated_at'])],
|
||||
'sort_order' => ['nullable', 'string', Rule::in(['asc', 'desc'])],
|
||||
];
|
||||
|
||||
return HookManager::applyFilters('core.mail_template.index_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 사용자 정의 유효성 검증 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string> 메시지
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'per_page.min' => __('mail_template.validation.per_page_min'),
|
||||
'per_page.max' => __('mail_template.validation.per_page_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\MailTemplate;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 메일 템플릿 미리보기 요청을 검증합니다.
|
||||
*/
|
||||
class MailTemplatePreviewRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 항상 true (권한은 permission 미들웨어에서 처리)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 유효성 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'subject' => ['required', 'string', 'max:500'],
|
||||
'body' => ['required', 'string', 'max:65535'],
|
||||
'variables' => ['nullable', 'array'],
|
||||
'variables.*.key' => ['required_with:variables', 'string', 'max:100'],
|
||||
];
|
||||
|
||||
return HookManager::applyFilters('core.mail_template.preview_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 사용자 정의 유효성 검증 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string> 메시지
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'subject.required' => __('mail_template.validation.subject_required'),
|
||||
'body.required' => __('mail_template.validation.body_required'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\MailTemplate;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Rules\LocaleRequiredTranslatable;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 메일 템플릿 수정 요청을 검증합니다.
|
||||
*/
|
||||
class UpdateMailTemplateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 항상 true (권한은 permission 미들웨어에서 처리)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 유효성 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'subject' => ['required', 'array', new LocaleRequiredTranslatable(maxLength: 500)],
|
||||
'body' => ['required', 'array', new LocaleRequiredTranslatable(maxLength: 65535)],
|
||||
'is_active' => ['sometimes', 'boolean'],
|
||||
];
|
||||
|
||||
return HookManager::applyFilters('core.mail_template.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 사용자 정의 유효성 검증 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string> 메시지
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'subject.required' => __('mail_template.validation.subject_required'),
|
||||
'body.required' => __('mail_template.validation.body_required'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Menu;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Menu;
|
||||
use App\Models\Module;
|
||||
use App\Models\Role;
|
||||
use App\Rules\LocaleRequiredTranslatable;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CreateMenuRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => ['required', new LocaleRequiredTranslatable(maxLength: 255)],
|
||||
'slug' => ['required', 'string', 'max:255', Rule::unique(Menu::class, 'slug')],
|
||||
'url' => 'nullable|string|max:500',
|
||||
'icon' => 'nullable|string|max:100',
|
||||
'parent_id' => ['nullable', 'integer', Rule::exists(Menu::class, 'id')],
|
||||
'order' => 'nullable|integer|min:0',
|
||||
'is_active' => 'nullable|boolean',
|
||||
'extension_type' => 'nullable|string|in:core,module,plugin',
|
||||
'extension_identifier' => 'nullable|string|max:255',
|
||||
'roles' => 'nullable|array',
|
||||
'roles.*' => ['integer', Rule::exists(Role::class, 'id')],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.menu.create_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => __('validation.menu.name.required'),
|
||||
'slug.required' => __('validation.menu.slug.required'),
|
||||
'slug.unique' => __('validation.menu.slug.unique'),
|
||||
'slug.max' => __('validation.menu.slug.max'),
|
||||
'url.max' => __('validation.menu.url.max'),
|
||||
'icon.max' => __('validation.menu.icon.max'),
|
||||
'order.integer' => __('validation.menu.order.integer'),
|
||||
'order.min' => __('validation.menu.order.min'),
|
||||
'parent_id.exists' => __('validation.menu.parent_id.exists'),
|
||||
'is_active.boolean' => __('validation.menu.is_active.boolean'),
|
||||
'extension_type.in' => __('validation.menu.extension_type.in'),
|
||||
'extension_identifier.max' => __('validation.menu.extension_identifier.max'),
|
||||
'roles.array' => __('validation.menu.roles.array'),
|
||||
'roles.*.integer' => __('validation.menu.roles.integer'),
|
||||
'roles.*.exists' => __('validation.menu.roles.exists'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 전처리
|
||||
*
|
||||
* 역호환성을 위해 문자열로 입력된 name을 다국어 배열로 자동 변환합니다.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$locales = config('app.translatable_locales', ['ko', 'en']);
|
||||
|
||||
if ($this->has('name') && is_string($this->name)) {
|
||||
$nameArray = [];
|
||||
foreach ($locales as $locale) {
|
||||
$nameArray[$locale] = $this->name;
|
||||
}
|
||||
$this->merge(['name' => $nameArray]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Menu;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 메뉴 목록 조회 요청 검증
|
||||
*
|
||||
* 메뉴 목록 조회 시 사용되는 필터링, 정렬 조건을 검증합니다.
|
||||
*/
|
||||
class MenuListRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 검색 가능한 필드 목록
|
||||
*/
|
||||
public const SEARCHABLE_FIELDS = ['name', 'slug', 'url'];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool 인증 여부
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// 'all'은 전체 필드 검색을 의미하는 특수 값
|
||||
$searchableFields = implode(',', array_merge(['all'], self::SEARCHABLE_FIELDS));
|
||||
|
||||
$rules = [
|
||||
// 활성화 상태 필터
|
||||
'is_active' => 'nullable|boolean',
|
||||
|
||||
// 다중 검색 조건
|
||||
'filters' => 'nullable|array|max:10',
|
||||
'filters.*.field' => "required_with:filters|string|in:{$searchableFields}",
|
||||
'filters.*.value' => 'required_with:filters|string|max:255',
|
||||
'filters.*.operator' => 'nullable|string|in:like,eq,starts_with,ends_with',
|
||||
|
||||
// 정렬
|
||||
'sort_by' => 'nullable|string|in:created_at,name,slug,order',
|
||||
'sort_order' => 'nullable|string|in:asc,desc',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.menu.list_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'is_active.boolean' => __('menu.validation.is_active_boolean'),
|
||||
'sort_by.in' => __('menu.validation.sort_by_invalid'),
|
||||
'sort_order.in' => __('menu.validation.sort_order_invalid'),
|
||||
// 다중 검색 조건 관련 메시지
|
||||
'filters.array' => __('menu.validation.filters_array'),
|
||||
'filters.max' => __('menu.validation.filters_max'),
|
||||
'filters.*.field.required_with' => __('menu.validation.filter_field_required'),
|
||||
'filters.*.field.in' => __('menu.validation.filter_field_invalid'),
|
||||
'filters.*.value.required_with' => __('menu.validation.filter_value_required'),
|
||||
'filters.*.value.max' => __('menu.validation.filter_value_max'),
|
||||
'filters.*.operator.in' => __('menu.validation.filter_operator_invalid'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
// value가 비어있는 filters 제거
|
||||
$filters = $this->filters;
|
||||
if (is_array($filters)) {
|
||||
$filters = array_filter($filters, function ($filter) {
|
||||
return ! empty($filter['value']);
|
||||
});
|
||||
// 인덱스 재정렬
|
||||
$filters = array_values($filters);
|
||||
$this->merge(['filters' => $filters ?: null]);
|
||||
}
|
||||
|
||||
// 기본값 설정
|
||||
$this->merge([
|
||||
'sort_by' => $this->sort_by ?? 'order',
|
||||
'sort_order' => $this->sort_order ?? 'asc',
|
||||
]);
|
||||
|
||||
// is_active 파라미터 처리 (문자열 'true'/'false'를 boolean으로 변환)
|
||||
if ($this->has('is_active') && $this->is_active !== null) {
|
||||
$isActive = $this->is_active;
|
||||
if (is_string($isActive)) {
|
||||
$isActive = filter_var($isActive, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||
}
|
||||
$this->merge(['is_active' => $isActive]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Menu;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Menu;
|
||||
use App\Rules\NotCircularParent;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateMenuOrderRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'parent_menus' => 'required|array|min:1',
|
||||
'parent_menus.*.id' => ['required', 'integer', Rule::exists(Menu::class, 'id')],
|
||||
'parent_menus.*.order' => 'required|integer|min:1',
|
||||
'child_menus' => 'sometimes|array',
|
||||
'child_menus.*.*.id' => ['required', 'integer', Rule::exists(Menu::class, 'id')],
|
||||
'child_menus.*.*.order' => 'required|integer|min:1',
|
||||
'moved_items' => 'sometimes|array',
|
||||
'moved_items.*.id' => ['required', 'integer', Rule::exists(Menu::class, 'id')],
|
||||
'moved_items.*.new_parent_id' => ['nullable', 'integer', Rule::exists(Menu::class, 'id')],
|
||||
];
|
||||
|
||||
// moved_items 각 항목에 순환 참조 검증 추가
|
||||
$movedItems = $this->input('moved_items', []);
|
||||
foreach ($movedItems as $index => $movedItem) {
|
||||
if (isset($movedItem['id'])) {
|
||||
$rules["moved_items.{$index}.new_parent_id"][] = new NotCircularParent((int) $movedItem['id']);
|
||||
}
|
||||
}
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.menu.update_order_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'parent_menus.required' => __('validation.menu.parent_menus.required'),
|
||||
'parent_menus.array' => __('validation.menu.parent_menus.array'),
|
||||
'parent_menus.min' => __('validation.menu.parent_menus.min'),
|
||||
'parent_menus.*.id.required' => __('validation.menu.parent_menus.id.required'),
|
||||
'parent_menus.*.id.integer' => __('validation.menu.parent_menus.id.integer'),
|
||||
'parent_menus.*.id.exists' => __('validation.menu.parent_menus.id.exists'),
|
||||
'parent_menus.*.order.required' => __('validation.menu.parent_menus.order.required'),
|
||||
'parent_menus.*.order.integer' => __('validation.menu.parent_menus.order.integer'),
|
||||
'parent_menus.*.order.min' => __('validation.menu.parent_menus.order.min'),
|
||||
'child_menus.array' => __('validation.menu.child_menus.array'),
|
||||
'child_menus.*.*.id.required' => __('validation.menu.child_menus.id.required'),
|
||||
'child_menus.*.*.id.integer' => __('validation.menu.child_menus.id.integer'),
|
||||
'child_menus.*.*.id.exists' => __('validation.menu.child_menus.id.exists'),
|
||||
'child_menus.*.*.order.required' => __('validation.menu.child_menus.order.required'),
|
||||
'child_menus.*.*.order.integer' => __('validation.menu.child_menus.order.integer'),
|
||||
'child_menus.*.*.order.min' => __('validation.menu.child_menus.order.min'),
|
||||
'moved_items.array' => __('validation.menu.moved_items.array'),
|
||||
'moved_items.*.id.required' => __('validation.menu.moved_items.id.required'),
|
||||
'moved_items.*.id.integer' => __('validation.menu.moved_items.id.integer'),
|
||||
'moved_items.*.id.exists' => __('validation.menu.moved_items.id.exists'),
|
||||
'moved_items.*.new_parent_id.integer' => __('validation.menu.moved_items.new_parent_id.integer'),
|
||||
'moved_items.*.new_parent_id.exists' => __('validation.menu.moved_items.new_parent_id.exists'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Menu;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Menu;
|
||||
use App\Models\Module;
|
||||
use App\Models\Role;
|
||||
use App\Rules\LocaleRequiredTranslatable;
|
||||
use App\Rules\NotSelfParent;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateMenuRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// Route Model Binding으로 Menu 모델을 받으므로 menu->id 사용
|
||||
$menuId = $this->route('menu')?->id;
|
||||
|
||||
$rules = [
|
||||
'name' => ['nullable', new LocaleRequiredTranslatable(maxLength: 255)],
|
||||
'slug' => ['required', 'string', 'max:255', Rule::unique(Menu::class, 'slug')->ignore($menuId)],
|
||||
'url' => 'nullable|string|max:500',
|
||||
'icon' => 'nullable|string|max:100',
|
||||
'parent_id' => ['nullable', 'integer', Rule::exists(Menu::class, 'id'), new NotSelfParent($menuId)],
|
||||
'order' => 'nullable|integer|min:0',
|
||||
'is_active' => 'nullable|boolean',
|
||||
'extension_type' => 'nullable|string|in:core,module,plugin',
|
||||
'extension_identifier' => 'nullable|string|max:255',
|
||||
'roles' => 'nullable|array',
|
||||
'roles.*' => ['integer', Rule::exists(Role::class, 'id')],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.menu.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => __('validation.menu.name.required'),
|
||||
'slug.required' => __('validation.menu.slug.required'),
|
||||
'slug.unique' => __('validation.menu.slug.unique'),
|
||||
'slug.max' => __('validation.menu.slug.max'),
|
||||
'url.max' => __('validation.menu.url.max'),
|
||||
'icon.max' => __('validation.menu.icon.max'),
|
||||
'order.integer' => __('validation.menu.order.integer'),
|
||||
'order.min' => __('validation.menu.order.min'),
|
||||
'parent_id.exists' => __('validation.menu.parent_id.exists'),
|
||||
'is_active.boolean' => __('validation.menu.is_active.boolean'),
|
||||
'extension_type.in' => __('validation.menu.extension_type.in'),
|
||||
'extension_identifier.max' => __('validation.menu.extension_identifier.max'),
|
||||
'roles.array' => __('validation.menu.roles.array'),
|
||||
'roles.*.integer' => __('validation.menu.roles.integer'),
|
||||
'roles.*.exists' => __('validation.menu.roles.exists'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 전처리
|
||||
*
|
||||
* 역호환성을 위해 문자열로 입력된 name을 다국어 배열로 자동 변환합니다.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$locales = config('app.translatable_locales', ['ko', 'en']);
|
||||
|
||||
if ($this->has('name') && is_string($this->name)) {
|
||||
$nameArray = [];
|
||||
foreach ($locales as $locale) {
|
||||
$nameArray[$locale] = $this->name;
|
||||
}
|
||||
$this->merge(['name' => $nameArray]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ActivateModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'module_name' => 'required|string|max:255',
|
||||
'force' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.activate_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'module_name.required' => __('modules.validation.name_required'),
|
||||
'module_name.string' => __('modules.validation.name_string'),
|
||||
'module_name.max' => __('modules.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DeactivateModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'module_name' => 'required|string|max:255',
|
||||
'force' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.deactivate_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'module_name.required' => __('modules.validation.name_required'),
|
||||
'module_name.string' => __('modules.validation.name_string'),
|
||||
'module_name.max' => __('modules.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 모듈 목록 조회 요청
|
||||
*
|
||||
* 다중 검색 조건을 지원합니다.
|
||||
* - search: 단일 검색어 (이름, 식별자, 설명, 벤더 OR 검색) - 하위 호환성
|
||||
* - filters: 다중 검색 조건 (AND 조건)
|
||||
* - with[]: 추가 데이터 포함 (예: custom_menus)
|
||||
*/
|
||||
class IndexModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 검색 가능한 필드 목록
|
||||
*/
|
||||
public const SEARCHABLE_FIELDS = ['name', 'identifier', 'description', 'vendor'];
|
||||
|
||||
/**
|
||||
* with 파라미터로 요청 가능한 추가 데이터 목록
|
||||
*/
|
||||
public const ALLOWED_WITH_OPTIONS = ['custom_menus'];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$searchableFields = implode(',', self::SEARCHABLE_FIELDS);
|
||||
$allowedWithOptions = implode(',', self::ALLOWED_WITH_OPTIONS);
|
||||
|
||||
$rules = [
|
||||
// 단일 검색어 (하위 호환성 - 이름, 식별자, 설명, 벤더 OR 검색)
|
||||
'search' => 'nullable|string|max:255',
|
||||
|
||||
// 다중 검색 조건
|
||||
'filters' => 'nullable|array|max:10',
|
||||
'filters.*.field' => "required_with:filters|string|in:{$searchableFields}",
|
||||
'filters.*.value' => 'required_with:filters|string|max:255',
|
||||
'filters.*.operator' => 'nullable|string|in:like,eq,starts_with,ends_with',
|
||||
|
||||
// 상태 필터
|
||||
'status' => 'nullable|string|in:installed,not_installed,active,inactive',
|
||||
|
||||
// 추가 데이터 포함
|
||||
'with' => 'nullable|array|max:5',
|
||||
'with.*' => "string|in:{$allowedWithOptions}",
|
||||
|
||||
// 페이지네이션
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.index_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'search.max' => __('modules.validation.search_max'),
|
||||
'filters.max' => __('modules.validation.filters_max'),
|
||||
'filters.*.field.required_with' => __('modules.validation.filter_field_required'),
|
||||
'filters.*.field.in' => __('modules.validation.filter_field_invalid'),
|
||||
'filters.*.value.required_with' => __('modules.validation.filter_value_required'),
|
||||
'filters.*.value.max' => __('modules.validation.filter_value_max'),
|
||||
'filters.*.operator.in' => __('modules.validation.filter_operator_invalid'),
|
||||
'status.in' => __('modules.validation.status_invalid'),
|
||||
'with.max' => __('modules.validation.with_max'),
|
||||
'with.*.in' => __('modules.validation.with_invalid'),
|
||||
'per_page.min' => __('modules.validation.per_page_min'),
|
||||
'per_page.max' => __('modules.validation.per_page_max'),
|
||||
'page.min' => __('modules.validation.page_min'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* with 파라미터에 특정 옵션이 포함되어 있는지 확인합니다.
|
||||
*
|
||||
* @param string $option 확인할 옵션명
|
||||
* @return bool 포함 여부
|
||||
*/
|
||||
public function hasWithOption(string $option): bool
|
||||
{
|
||||
$withOptions = $this->validated('with', []);
|
||||
|
||||
return in_array($option, $withOptions, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 파일에서 모듈 설치 요청
|
||||
*/
|
||||
class InstallModuleFromFileRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$maxSize = config('module.upload_max_size', 50) * 1024; // MB를 KB로 변환
|
||||
|
||||
$rules = [
|
||||
'file' => [
|
||||
'required',
|
||||
'file',
|
||||
'mimes:zip',
|
||||
'max:' . $maxSize,
|
||||
],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.install_from_file_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
$maxSize = config('module.upload_max_size', 50);
|
||||
|
||||
return [
|
||||
'file.required' => __('modules.validation.file_required'),
|
||||
'file.file' => __('modules.validation.file_invalid'),
|
||||
'file.mimes' => __('modules.validation.file_must_be_zip'),
|
||||
'file.max' => __('modules.validation.file_max_size', ['size' => $maxSize]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* GitHub에서 모듈 설치 요청
|
||||
*/
|
||||
class InstallModuleFromGithubRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'github_url' => [
|
||||
'required',
|
||||
'url',
|
||||
'regex:/^https?:\/\/(www\.)?github\.com\/[a-zA-Z0-9\-_]+\/[a-zA-Z0-9\-_]+\/?$/',
|
||||
],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.install_from_github_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'github_url.required' => __('modules.validation.github_url_required'),
|
||||
'github_url.url' => __('modules.validation.github_url_invalid'),
|
||||
'github_url.regex' => __('modules.validation.github_url_format'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Rules\ValidExtensionIdentifier;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class InstallModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'module_name' => ['required', 'string', 'max:255', new ValidExtensionIdentifier],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.install_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'module_name.required' => __('modules.validation.name_required'),
|
||||
'module_name.string' => __('modules.validation.name_string'),
|
||||
'module_name.max' => __('modules.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RefreshModuleLayoutsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'module_name' => 'required|string|max:255',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.refresh_layouts_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'module_name.required' => __('modules.validation.name_required'),
|
||||
'module_name.string' => __('modules.validation.name_string'),
|
||||
'module_name.max' => __('modules.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UninstallModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'module_name' => 'required|string|max:255',
|
||||
'delete_data' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.uninstall_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'module_name.required' => __('modules.validation.name_required'),
|
||||
'module_name.string' => __('modules.validation.name_string'),
|
||||
'module_name.max' => __('modules.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Permission;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Rules\LocaleRequiredTranslatable;
|
||||
use App\Rules\TranslatableField;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 권한 업데이트 요청 검증
|
||||
*
|
||||
* 권한의 name, description을 업데이트할 수 있습니다.
|
||||
* name과 description은 다국어 필드로 처리됩니다.
|
||||
*/
|
||||
class UpdatePermissionRequest 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 LocaleRequiredTranslatable(maxLength: 255)],
|
||||
'description' => ['nullable', new TranslatableField(maxLength: 1000)],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.permission.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => __('validation..name.required'),
|
||||
'description.max' => __('validation.permission.description.max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Plugin;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 플러그인 활성화 요청 검증
|
||||
*
|
||||
* 플러그인 활성화 시 필요한 데이터를 검증합니다.
|
||||
*/
|
||||
class ActivatePluginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'plugin_name' => ['required', 'string', 'max:255'],
|
||||
'force' => ['sometimes', 'boolean'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.plugin.activate_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'plugin_name.required' => __('plugins.validation.plugin_name_required'),
|
||||
'plugin_name.string' => __('plugins.validation.plugin_name_string'),
|
||||
'plugin_name.max' => __('plugins.validation.plugin_name_max', ['max' => 255]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Plugin;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 플러그인 비활성화 요청 검증
|
||||
*
|
||||
* 플러그인 비활성화 시 필요한 데이터를 검증합니다.
|
||||
*/
|
||||
class DeactivatePluginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'plugin_name' => ['required', 'string', 'max:255'],
|
||||
'force' => ['sometimes', 'boolean'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.plugin.deactivate_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'plugin_name.required' => __('plugins.validation.plugin_name_required'),
|
||||
'plugin_name.string' => __('plugins.validation.plugin_name_string'),
|
||||
'plugin_name.max' => __('plugins.validation.plugin_name_max', ['max' => 255]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Plugin;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 플러그인 목록 조회 요청
|
||||
*
|
||||
* 다중 검색 조건을 지원합니다.
|
||||
* - search: 단일 검색어 (이름, 식별자, 설명, 벤더 OR 검색) - 하위 호환성
|
||||
* - filters: 다중 검색 조건 (AND 조건)
|
||||
*/
|
||||
class IndexPluginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 검색 가능한 필드 목록
|
||||
*/
|
||||
public const SEARCHABLE_FIELDS = ['name', 'identifier', 'description', 'vendor'];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$searchableFields = implode(',', self::SEARCHABLE_FIELDS);
|
||||
|
||||
$rules = [
|
||||
// 단일 검색어 (하위 호환성 - 이름, 식별자, 설명, 벤더 OR 검색)
|
||||
'search' => 'nullable|string|max:255',
|
||||
|
||||
// 다중 검색 조건
|
||||
'filters' => 'nullable|array|max:10',
|
||||
'filters.*.field' => "required_with:filters|string|in:{$searchableFields}",
|
||||
'filters.*.value' => 'required_with:filters|string|max:255',
|
||||
'filters.*.operator' => 'nullable|string|in:like,eq,starts_with,ends_with',
|
||||
|
||||
// 상태 필터
|
||||
'status' => 'nullable|string|in:installed,uninstalled,active,inactive',
|
||||
|
||||
// 페이지네이션
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.plugin.index_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'search.max' => __('plugins.validation.search_max'),
|
||||
'filters.max' => __('plugins.validation.filters_max'),
|
||||
'filters.*.field.required_with' => __('plugins.validation.filter_field_required'),
|
||||
'filters.*.field.in' => __('plugins.validation.filter_field_invalid'),
|
||||
'filters.*.value.required_with' => __('plugins.validation.filter_value_required'),
|
||||
'filters.*.value.max' => __('plugins.validation.filter_value_max'),
|
||||
'filters.*.operator.in' => __('plugins.validation.filter_operator_invalid'),
|
||||
'status.in' => __('plugins.validation.status_invalid'),
|
||||
'per_page.min' => __('plugins.validation.per_page_min'),
|
||||
'per_page.max' => __('plugins.validation.per_page_max'),
|
||||
'page.min' => __('plugins.validation.page_min'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Plugin;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 파일에서 플러그인 설치 요청
|
||||
*/
|
||||
class InstallPluginFromFileRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$maxSize = config('plugin.upload_max_size', 50) * 1024; // MB를 KB로 변환
|
||||
|
||||
$rules = [
|
||||
'file' => [
|
||||
'required',
|
||||
'file',
|
||||
'mimes:zip',
|
||||
'max:'.$maxSize,
|
||||
],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.plugin.install_from_file_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
$maxSize = config('plugin.upload_max_size', 50);
|
||||
|
||||
return [
|
||||
'file.required' => __('plugins.validation.file_required'),
|
||||
'file.file' => __('plugins.validation.file_invalid'),
|
||||
'file.mimes' => __('plugins.validation.file_must_be_zip'),
|
||||
'file.max' => __('plugins.validation.file_max_size', ['size' => $maxSize]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Plugin;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* GitHub에서 플러그인 설치 요청
|
||||
*/
|
||||
class InstallPluginFromGithubRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'github_url' => [
|
||||
'required',
|
||||
'url',
|
||||
'regex:/^https?:\/\/(www\.)?github\.com\/[a-zA-Z0-9\-_]+\/[a-zA-Z0-9\-_]+\/?$/',
|
||||
],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.plugin.install_from_github_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'github_url.required' => __('plugins.validation.github_url_required'),
|
||||
'github_url.url' => __('plugins.validation.github_url_invalid'),
|
||||
'github_url.regex' => __('plugins.validation.github_url_format'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Plugin;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Rules\ValidExtensionIdentifier;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 플러그인 설치 요청 검증
|
||||
*
|
||||
* 플러그인 설치 시 필요한 데이터를 검증합니다.
|
||||
*/
|
||||
class InstallPluginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'plugin_name' => ['required', 'string', 'max:255', new ValidExtensionIdentifier],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.plugin.install_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'plugin_name.required' => __('plugins.validation.plugin_name_required'),
|
||||
'plugin_name.string' => __('plugins.validation.plugin_name_string'),
|
||||
'plugin_name.max' => __('plugins.validation.plugin_name_max', ['max' => 255]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Plugin;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RefreshPluginLayoutsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'plugin_name' => 'required|string|max:255',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.plugin.refresh_layouts_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'plugin_name.required' => __('plugins.validation.name_required'),
|
||||
'plugin_name.string' => __('plugins.validation.name_string'),
|
||||
'plugin_name.max' => __('plugins.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Plugin;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 플러그인 제거 요청 검증
|
||||
*
|
||||
* 플러그인 제거 시 필요한 데이터를 검증합니다.
|
||||
*/
|
||||
class UninstallPluginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'plugin_name' => ['required', 'string', 'max:255'],
|
||||
'delete_data' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.plugin.uninstall_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'plugin_name.required' => __('plugins.validation.plugin_name_required'),
|
||||
'plugin_name.string' => __('plugins.validation.plugin_name_string'),
|
||||
'plugin_name.max' => __('plugins.validation.plugin_name_max', ['max' => 255]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Plugin;
|
||||
|
||||
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 UpdatePluginRequest 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.plugin.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'status.in' => __('validation.plugin.status.in'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Public\Module;
|
||||
|
||||
use App\Rules\AllowedModuleFileType;
|
||||
use App\Rules\SafeModulePath;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ServeModuleAssetRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// 모듈 식별자로부터 기준 경로 구성 (모듈 루트)
|
||||
$identifier = $this->route('identifier');
|
||||
$basePath = base_path("modules/{$identifier}");
|
||||
|
||||
return [
|
||||
'identifier' => ['required', 'string'],
|
||||
'path' => [
|
||||
'required',
|
||||
'string',
|
||||
new SafeModulePath($basePath),
|
||||
new AllowedModuleFileType(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증을 위한 데이터 준비
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
// 라우트 파라미터를 검증 데이터에 병합
|
||||
$this->merge([
|
||||
'identifier' => $this->route('identifier'),
|
||||
'path' => $this->route('path'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'identifier.required' => __('validation.asset.identifier.required'),
|
||||
'identifier.string' => __('validation.asset.identifier.string'),
|
||||
'path.required' => __('validation.asset.path.required'),
|
||||
'path.string' => __('validation.asset.path.string'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Public\Plugin;
|
||||
|
||||
use App\Rules\AllowedPluginFileType;
|
||||
use App\Rules\SafePluginPath;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ServePluginAssetRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// 플러그인 식별자로부터 기준 경로 구성 (플러그인 루트)
|
||||
$identifier = $this->route('identifier');
|
||||
$basePath = base_path("plugins/{$identifier}");
|
||||
|
||||
return [
|
||||
'identifier' => ['required', 'string'],
|
||||
'path' => [
|
||||
'required',
|
||||
'string',
|
||||
new SafePluginPath($basePath),
|
||||
new AllowedPluginFileType(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증을 위한 데이터 준비
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
// 라우트 파라미터를 검증 데이터에 병합
|
||||
$this->merge([
|
||||
'identifier' => $this->route('identifier'),
|
||||
'path' => $this->route('path'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'identifier.required' => __('validation.asset.identifier.required'),
|
||||
'identifier.string' => __('validation.asset.identifier.string'),
|
||||
'path.required' => __('validation.asset.path.required'),
|
||||
'path.string' => __('validation.asset.path.string'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Public;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 통합 검색 요청 클래스
|
||||
*
|
||||
* 검색어, 페이지네이션 등 기본 검색 파라미터를 검증합니다.
|
||||
* 모듈별 추가 파라미터(type, sort, board_slug 등)는 훅을 통해 확장 가능합니다.
|
||||
*/
|
||||
class SearchRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
// 기본 검색 파라미터
|
||||
'q' => ['nullable', 'string', 'max:200'],
|
||||
'type' => ['nullable', 'string'],
|
||||
'sort' => ['nullable', 'string'],
|
||||
'page' => ['nullable', 'integer', 'min:1'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
// 예: sort의 in 규칙, board_slug 등 모듈별 파라미터
|
||||
return HookManager::applyFilters('core.search.validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'q.max' => __('search.validation.q_max'),
|
||||
'page.integer' => __('search.validation.page_integer'),
|
||||
'page.min' => __('search.validation.page_min'),
|
||||
'per_page.integer' => __('search.validation.per_page_integer'),
|
||||
'per_page.min' => __('search.validation.per_page_min'),
|
||||
'per_page.max' => __('search.validation.per_page_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Public\Template;
|
||||
|
||||
use App\Rules\AllowedTemplateFileType;
|
||||
use App\Rules\SafeTemplatePath;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ServeTemplateAssetRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// 템플릿 식별자로부터 기준 경로 구성
|
||||
$identifier = $this->route('identifier');
|
||||
$basePath = base_path("templates/{$identifier}/dist");
|
||||
|
||||
return [
|
||||
'identifier' => ['required', 'string'],
|
||||
'path' => [
|
||||
'required',
|
||||
'string',
|
||||
new SafeTemplatePath($basePath),
|
||||
new AllowedTemplateFileType(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증을 위한 데이터 준비
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
// 라우트 파라미터를 검증 데이터에 병합
|
||||
$this->merge([
|
||||
'identifier' => $this->route('identifier'),
|
||||
'path' => $this->route('path'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'identifier.required' => __('validation.asset.identifier.required'),
|
||||
'identifier.string' => __('validation.asset.identifier.string'),
|
||||
'path.required' => __('validation.asset.path.required'),
|
||||
'path.string' => __('validation.asset.path.string'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Role;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RoleListRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'page' => 'integer|min:1',
|
||||
'per_page' => 'integer|min:1|max:100',
|
||||
'search' => 'nullable|string|max:255',
|
||||
'is_active' => 'nullable|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'page.integer' => __('validation.integer', ['attribute' => 'page']),
|
||||
'page.min' => __('validation.min.numeric', ['attribute' => 'page', 'min' => 1]),
|
||||
'per_page.integer' => __('validation.integer', ['attribute' => 'per_page']),
|
||||
'per_page.min' => __('validation.min.numeric', ['attribute' => 'per_page', 'min' => 1]),
|
||||
'per_page.max' => __('validation.max.numeric', ['attribute' => 'per_page', 'max' => 100]),
|
||||
'search.max' => __('validation.max.string', ['attribute' => 'search', 'max' => 255]),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 전처리
|
||||
*
|
||||
* 쿼리 파라미터 문자열 "true"/"false"를 boolean으로 변환합니다.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->has('is_active') && is_string($this->is_active)) {
|
||||
$this->merge([
|
||||
'is_active' => filter_var($this->is_active, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Role;
|
||||
|
||||
use App\Enums\ScopeType;
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Role;
|
||||
use App\Rules\LocaleRequiredTranslatable;
|
||||
use App\Rules\TranslatableField;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 역할 생성 요청 검증
|
||||
*/
|
||||
class StoreRoleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* @return bool 권한 여부
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'identifier' => ['required', 'string', 'max:100', 'regex:/^[a-z][a-z0-9_]*$/', Rule::unique(Role::class, 'identifier')],
|
||||
'name' => ['required', new LocaleRequiredTranslatable(maxLength: 100)],
|
||||
'description' => ['nullable', new TranslatableField(maxLength: 500)],
|
||||
'is_active' => 'boolean',
|
||||
'permissions' => 'nullable|array',
|
||||
'permissions.*.id' => ['required', 'integer', Rule::exists(Permission::class, 'id')],
|
||||
'permissions.*.scope_type' => ['nullable', Rule::enum(ScopeType::class)],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.role.store_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'identifier.required' => __('role.validation.identifier_required'),
|
||||
'identifier.regex' => __('role.validation.identifier_format'),
|
||||
'identifier.unique' => __('role.validation.identifier_unique'),
|
||||
'identifier.max' => __('role.validation.identifier_max'),
|
||||
'name.required' => __('role.validation.name_required'),
|
||||
'permissions.array' => __('role.validation.permission_ids_array'),
|
||||
'permissions.*.id.exists' => __('role.validation.permission_ids_exists'),
|
||||
'permissions.*.id.integer' => __('role.validation.permission_ids_integer'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 전처리
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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)) {
|
||||
$descArray = [];
|
||||
foreach ($locales as $locale) {
|
||||
$descArray[$locale] = $this->description;
|
||||
}
|
||||
$this->merge(['description' => $descArray]);
|
||||
}
|
||||
|
||||
// is_active 기본값
|
||||
if (! $this->has('is_active')) {
|
||||
$this->merge(['is_active' => true]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Role;
|
||||
|
||||
use App\Enums\ScopeType;
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Permission;
|
||||
use App\Rules\LocaleRequiredTranslatable;
|
||||
use App\Rules\TranslatableField;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 역할 수정 요청 검증
|
||||
*
|
||||
* 역할의 name, description, is_active, permission_ids를 수정할 수 있습니다.
|
||||
* name과 description은 다국어 필드로 처리됩니다.
|
||||
*/
|
||||
class UpdateRoleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* @return bool 권한 여부
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 전처리
|
||||
*
|
||||
* 역호환성을 위해 문자열로 들어온 name, description을
|
||||
* 다국어 배열 형식으로 자동 변환합니다.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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' => ['sometimes', 'required', new LocaleRequiredTranslatable(maxLength: 100)],
|
||||
'description' => ['nullable', new TranslatableField(maxLength: 500)],
|
||||
'is_active' => 'sometimes|boolean',
|
||||
'permissions' => 'nullable|array',
|
||||
'permissions.*.id' => ['required', 'integer', Rule::exists(Permission::class, 'id')],
|
||||
'permissions.*.scope_type' => ['nullable', Rule::enum(ScopeType::class)],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.role.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => __('role.validation.name_required'),
|
||||
'permissions.array' => __('role.validation.permission_ids_array'),
|
||||
'permissions.*.id.exists' => __('role.validation.permission_ids_exists'),
|
||||
'permissions.*.id.integer' => __('role.validation.permission_ids_integer'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Schedule;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Schedule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class BulkDeleteScheduleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'ids' => 'required|array|min:1',
|
||||
'ids.*' => ['required', 'integer', Rule::exists(Schedule::class, 'id')],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.schedule.bulk_delete_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'ids.required' => __('schedule.validation.ids_required'),
|
||||
'ids.array' => __('schedule.validation.ids_array'),
|
||||
'ids.min' => __('schedule.validation.ids_min'),
|
||||
'ids.*.integer' => __('schedule.validation.id_integer'),
|
||||
'ids.*.exists' => __('schedule.validation.id_exists'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Schedule;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Schedule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class BulkUpdateScheduleStatusRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'ids' => 'required|array|min:1',
|
||||
'ids.*' => ['required', 'integer', Rule::exists(Schedule::class, 'id')],
|
||||
'is_active' => 'required|boolean',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.schedule.bulk_update_status_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'ids.required' => __('schedule.validation.ids_required'),
|
||||
'ids.array' => __('schedule.validation.ids_array'),
|
||||
'ids.min' => __('schedule.validation.ids_min'),
|
||||
'ids.*.integer' => __('schedule.validation.id_integer'),
|
||||
'ids.*.exists' => __('schedule.validation.id_exists'),
|
||||
'is_active.required' => __('schedule.validation.is_active_required'),
|
||||
'is_active.boolean' => __('schedule.validation.is_active_boolean'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Schedule;
|
||||
|
||||
use App\Enums\ExtensionOwnerType;
|
||||
use App\Enums\ScheduleFrequency;
|
||||
use App\Enums\ScheduleType;
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CreateScheduleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$types = implode(',', ScheduleType::values());
|
||||
$frequencies = implode(',', ScheduleFrequency::values());
|
||||
|
||||
$rules = [
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string|max:1000',
|
||||
'type' => "required|string|in:{$types}",
|
||||
'command' => 'required|string|max:2000',
|
||||
'expression' => 'required|string|max:100',
|
||||
'frequency' => "required|string|in:{$frequencies}",
|
||||
'without_overlapping' => 'boolean',
|
||||
'run_in_maintenance' => 'boolean',
|
||||
'timeout' => 'nullable|integer|min:1|max:86400',
|
||||
'is_active' => 'boolean',
|
||||
'extension_type' => 'nullable|string|in:'.implode(',', ExtensionOwnerType::values()),
|
||||
'extension_identifier' => 'nullable|string|max:255|required_with:extension_type',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.schedule.create_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => __('schedule.validation.name_required'),
|
||||
'name.max' => __('schedule.validation.name_max'),
|
||||
'type.required' => __('schedule.validation.type_required'),
|
||||
'type.in' => __('schedule.validation.type_invalid'),
|
||||
'command.required' => __('schedule.validation.command_required'),
|
||||
'command.max' => __('schedule.validation.command_max'),
|
||||
'expression.required' => __('schedule.validation.expression_required'),
|
||||
'expression.max' => __('schedule.validation.expression_max'),
|
||||
'frequency.required' => __('schedule.validation.frequency_required'),
|
||||
'frequency.in' => __('schedule.validation.frequency_invalid'),
|
||||
'timeout.integer' => __('schedule.validation.timeout_integer'),
|
||||
'timeout.min' => __('schedule.validation.timeout_min'),
|
||||
'timeout.max' => __('schedule.validation.timeout_max'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'without_overlapping' => $this->without_overlapping ?? false,
|
||||
'run_in_maintenance' => $this->run_in_maintenance ?? false,
|
||||
'is_active' => $this->is_active ?? true,
|
||||
'created_by' => Auth::id(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증된 데이터 반환
|
||||
*/
|
||||
public function validatedWithCreator(): array
|
||||
{
|
||||
return array_merge($this->validated(), [
|
||||
'created_by' => Auth::id(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Schedule;
|
||||
|
||||
use App\Enums\ScheduleResultStatus;
|
||||
use App\Enums\ScheduleTriggerType;
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ScheduleHistoryListRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$statuses = implode(',', array_diff(ScheduleResultStatus::values(), ['never']));
|
||||
$triggerTypes = implode(',', ScheduleTriggerType::values());
|
||||
|
||||
$rules = [
|
||||
'page' => 'integer|min:1',
|
||||
'per_page' => 'integer|min:1|max:100',
|
||||
|
||||
// 필터
|
||||
'status' => "nullable|string|in:{$statuses}",
|
||||
'trigger_type' => "nullable|string|in:{$triggerTypes}",
|
||||
|
||||
// 날짜 필터
|
||||
'started_from' => 'nullable|date',
|
||||
'started_to' => 'nullable|date|after_or_equal:started_from',
|
||||
|
||||
// 정렬
|
||||
'sort_by' => 'nullable|string|in:started_at,ended_at,duration,status',
|
||||
'sort_order' => 'nullable|string|in:asc,desc',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.schedule.history_list_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'page.integer' => __('schedule.validation.page_integer'),
|
||||
'page.min' => __('schedule.validation.page_min'),
|
||||
'per_page.integer' => __('schedule.validation.per_page_integer'),
|
||||
'per_page.min' => __('schedule.validation.per_page_min'),
|
||||
'per_page.max' => __('schedule.validation.per_page_max'),
|
||||
'status.in' => __('schedule.validation.history_status_invalid'),
|
||||
'trigger_type.in' => __('schedule.validation.trigger_type_invalid'),
|
||||
'started_from.date' => __('schedule.validation.started_from_invalid'),
|
||||
'started_to.date' => __('schedule.validation.started_to_invalid'),
|
||||
'started_to.after_or_equal' => __('schedule.validation.started_to_after_from'),
|
||||
'sort_by.in' => __('schedule.validation.sort_by_invalid'),
|
||||
'sort_order.in' => __('schedule.validation.sort_order_invalid'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'per_page' => $this->per_page ?? 15,
|
||||
'page' => $this->page ?? 1,
|
||||
'sort_by' => $this->sort_by ?? 'started_at',
|
||||
'sort_order' => $this->sort_order ?? 'desc',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Schedule;
|
||||
|
||||
use App\Enums\ExtensionOwnerType;
|
||||
use App\Enums\ScheduleFrequency;
|
||||
use App\Enums\ScheduleResultStatus;
|
||||
use App\Enums\ScheduleType;
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ScheduleListRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 검색 가능한 필드 목록
|
||||
*/
|
||||
public const SEARCHABLE_FIELDS = ['name', 'description', 'command'];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$searchableFields = implode(',', array_merge(['all'], self::SEARCHABLE_FIELDS));
|
||||
$types = implode(',', ScheduleType::values());
|
||||
$frequencies = implode(',', ScheduleFrequency::values());
|
||||
$results = implode(',', ScheduleResultStatus::values());
|
||||
|
||||
$rules = [
|
||||
'page' => 'integer|min:1',
|
||||
'per_page' => 'integer|min:1|max:100',
|
||||
|
||||
// 다중 검색 조건
|
||||
'filters' => 'nullable|array|max:10',
|
||||
'filters.*.field' => "required_with:filters|string|in:{$searchableFields}",
|
||||
'filters.*.value' => 'required_with:filters|string|max:255',
|
||||
'filters.*.operator' => 'nullable|string|in:like,eq,starts_with,ends_with',
|
||||
|
||||
// 필터
|
||||
'type' => "nullable|string|in:{$types}",
|
||||
'frequency' => "nullable|string|in:{$frequencies}",
|
||||
'status' => 'nullable|string|in:active,inactive',
|
||||
'last_result' => "nullable|string|in:{$results}",
|
||||
'without_overlapping' => 'nullable|in:0,1',
|
||||
'run_in_maintenance' => 'nullable|in:0,1',
|
||||
'extension_type' => 'nullable|string|in:'.implode(',', ExtensionOwnerType::values()),
|
||||
'extension_identifier' => 'nullable|string|max:255',
|
||||
|
||||
// 날짜 필터
|
||||
'created_from' => 'nullable|date',
|
||||
'created_to' => 'nullable|date|after_or_equal:created_from',
|
||||
|
||||
// 정렬
|
||||
'sort_by' => 'nullable|string|in:created_at,name,next_run_at,last_run_at,is_active,last_result',
|
||||
'sort_order' => 'nullable|string|in:asc,desc',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.schedule.list_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'page.integer' => __('schedule.validation.page_integer'),
|
||||
'page.min' => __('schedule.validation.page_min'),
|
||||
'per_page.integer' => __('schedule.validation.per_page_integer'),
|
||||
'per_page.min' => __('schedule.validation.per_page_min'),
|
||||
'per_page.max' => __('schedule.validation.per_page_max'),
|
||||
'type.in' => __('schedule.validation.type_invalid'),
|
||||
'frequency.in' => __('schedule.validation.frequency_invalid'),
|
||||
'status.in' => __('schedule.validation.status_invalid'),
|
||||
'last_result.in' => __('schedule.validation.last_result_invalid'),
|
||||
'created_from.date' => __('schedule.validation.created_from_invalid'),
|
||||
'created_to.date' => __('schedule.validation.created_to_invalid'),
|
||||
'created_to.after_or_equal' => __('schedule.validation.created_to_after_from'),
|
||||
'sort_by.in' => __('schedule.validation.sort_by_invalid'),
|
||||
'sort_order.in' => __('schedule.validation.sort_order_invalid'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
// value가 비어있는 filters 제거
|
||||
$filters = $this->filters;
|
||||
if (is_array($filters)) {
|
||||
$filters = array_filter($filters, function ($filter) {
|
||||
return ! empty($filter['value']);
|
||||
});
|
||||
$filters = array_values($filters);
|
||||
$this->merge(['filters' => $filters ?: null]);
|
||||
}
|
||||
|
||||
// 기본값 설정
|
||||
$this->merge([
|
||||
'per_page' => $this->per_page ?? 15,
|
||||
'page' => $this->page ?? 1,
|
||||
'sort_by' => $this->sort_by ?? 'created_at',
|
||||
'sort_order' => $this->sort_order ?? 'desc',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Schedule;
|
||||
|
||||
use App\Enums\ExtensionOwnerType;
|
||||
use App\Enums\ScheduleFrequency;
|
||||
use App\Enums\ScheduleType;
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateScheduleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$types = implode(',', ScheduleType::values());
|
||||
$frequencies = implode(',', ScheduleFrequency::values());
|
||||
|
||||
$rules = [
|
||||
'name' => 'sometimes|required|string|max:255',
|
||||
'description' => 'nullable|string|max:1000',
|
||||
'type' => "sometimes|required|string|in:{$types}",
|
||||
'command' => 'sometimes|required|string|max:2000',
|
||||
'expression' => 'sometimes|required|string|max:100',
|
||||
'frequency' => "sometimes|required|string|in:{$frequencies}",
|
||||
'without_overlapping' => 'boolean',
|
||||
'run_in_maintenance' => 'boolean',
|
||||
'timeout' => 'nullable|integer|min:1|max:86400',
|
||||
'is_active' => 'boolean',
|
||||
'extension_type' => 'nullable|string|in:'.implode(',', ExtensionOwnerType::values()),
|
||||
'extension_identifier' => 'nullable|string|max:255|required_with:extension_type',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.schedule.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => __('schedule.validation.name_required'),
|
||||
'name.max' => __('schedule.validation.name_max'),
|
||||
'type.required' => __('schedule.validation.type_required'),
|
||||
'type.in' => __('schedule.validation.type_invalid'),
|
||||
'command.required' => __('schedule.validation.command_required'),
|
||||
'command.max' => __('schedule.validation.command_max'),
|
||||
'expression.required' => __('schedule.validation.expression_required'),
|
||||
'expression.max' => __('schedule.validation.expression_max'),
|
||||
'frequency.required' => __('schedule.validation.frequency_required'),
|
||||
'frequency.in' => __('schedule.validation.frequency_invalid'),
|
||||
'timeout.integer' => __('schedule.validation.timeout_integer'),
|
||||
'timeout.min' => __('schedule.validation.timeout_min'),
|
||||
'timeout.max' => __('schedule.validation.timeout_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Settings;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 앱 키 재생성 요청 FormRequest
|
||||
*
|
||||
* 앱 키 재생성 시 비밀번호 검증을 위한 요청 클래스입니다.
|
||||
*/
|
||||
class RegenerateAppKeyRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 최고 관리자 역할일 경우 true
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
// 최고 관리자만 허용 (role_id = 1 또는 super_admin 권한)
|
||||
return $this->user()?->hasRole('super_admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'password' => 'required|string',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.settings.regenerate_app_key_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'password.required' => __('settings.password_required'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,573 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Settings;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Attachment;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class SaveSettingsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 지원되는 언어 목록
|
||||
*/
|
||||
private const SUPPORTED_LANGUAGES = ['ko', 'en'];
|
||||
|
||||
/**
|
||||
* 지원되는 메일러 목록
|
||||
*/
|
||||
private const SUPPORTED_MAILERS = ['smtp', 'mailgun', 'ses'];
|
||||
|
||||
/**
|
||||
* 지원되는 암호화 방식 목록
|
||||
*/
|
||||
private const SUPPORTED_ENCRYPTIONS = ['tls', 'ssl', ''];
|
||||
|
||||
/**
|
||||
* 지원되는 스토리지 드라이버 목록
|
||||
*/
|
||||
private const SUPPORTED_STORAGE_DRIVERS = ['local', 's3'];
|
||||
|
||||
/**
|
||||
* 지원되는 S3 리전 목록
|
||||
*/
|
||||
private const SUPPORTED_S3_REGIONS = ['ap-northeast-2', 'ap-northeast-1', 'us-east-1', 'us-west-2', 'eu-west-1'];
|
||||
|
||||
/**
|
||||
* 지원되는 캐시 드라이버 목록
|
||||
*/
|
||||
private const SUPPORTED_CACHE_DRIVERS = ['file', 'redis', 'memcached'];
|
||||
|
||||
/**
|
||||
* 지원되는 세션 드라이버 목록
|
||||
*/
|
||||
private const SUPPORTED_SESSION_DRIVERS = ['file', 'database', 'redis'];
|
||||
|
||||
/**
|
||||
* 지원되는 큐 드라이버 목록
|
||||
*/
|
||||
private const SUPPORTED_QUEUE_DRIVERS = ['sync', 'database', 'redis'];
|
||||
|
||||
/**
|
||||
* 지원되는 웹소켓 프로토콜 목록
|
||||
*/
|
||||
private const SUPPORTED_WEBSOCKET_SCHEMES = ['http', 'https'];
|
||||
|
||||
/**
|
||||
* 지원되는 검색엔진 드라이버 기본 목록
|
||||
*/
|
||||
private const DEFAULT_SEARCH_ENGINE_DRIVERS = ['mysql-fulltext'];
|
||||
|
||||
/**
|
||||
* 지원되는 로그 드라이버 목록
|
||||
*/
|
||||
private const SUPPORTED_LOG_DRIVERS = ['single', 'daily'];
|
||||
|
||||
/**
|
||||
* 지원되는 로그 레벨 목록
|
||||
*/
|
||||
private const SUPPORTED_LOG_LEVELS = ['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency'];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 입력 데이터를 정규화합니다.
|
||||
*
|
||||
* site_logo 필드가 Attachment 객체 배열로 전송될 수 있으므로
|
||||
* 정수 ID 배열로 변환합니다.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$siteLogo = $this->input('general.site_logo');
|
||||
|
||||
if (is_array($siteLogo)) {
|
||||
$this->merge([
|
||||
'general' => array_merge($this->input('general', []), [
|
||||
'site_logo' => array_map(
|
||||
fn ($item) => is_array($item) ? ($item['id'] ?? $item) : $item,
|
||||
$siteLogo
|
||||
),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* nested 구조로 요청됩니다:
|
||||
* { _tab: 'general', general: { site_name: '...', ... } }
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$tab = $this->input('_tab', 'general');
|
||||
|
||||
$rules = [
|
||||
// 탭 식별자
|
||||
'_tab' => ['nullable', 'string', Rule::in(['general', 'mail', 'upload', 'seo', 'security', 'drivers', 'advanced'])],
|
||||
|
||||
// 각 탭의 컨테이너
|
||||
'general' => ['sometimes', 'array'],
|
||||
'mail' => ['sometimes', 'array'],
|
||||
'upload' => ['sometimes', 'array'],
|
||||
'seo' => ['sometimes', 'array'],
|
||||
'security' => ['sometimes', 'array'],
|
||||
'drivers' => ['sometimes', 'array'],
|
||||
'advanced' => ['sometimes', 'array'],
|
||||
|
||||
// 일반 설정
|
||||
'general.site_name' => $this->getTabRules($tab, 'general', 'string|max:100'),
|
||||
'general.site_url' => $this->getTabRules($tab, 'general', 'url|max:255'),
|
||||
'general.site_description' => ['nullable', 'string', 'max:500'],
|
||||
'general.admin_email' => $this->getTabRules($tab, 'general', 'email|max:255'),
|
||||
'general.timezone' => $this->getTabRules($tab, 'general', [Rule::in(config('app.supported_timezones', ['Asia/Seoul', 'UTC']))]),
|
||||
'general.language' => $this->getTabRules($tab, 'general', [Rule::in(self::SUPPORTED_LANGUAGES)]),
|
||||
'general.currency' => ['nullable', 'string', 'max:10'],
|
||||
'general.maintenance_mode' => ['nullable', 'boolean'],
|
||||
'general.site_logo' => ['nullable', 'array'],
|
||||
'general.site_logo.*' => ['integer', Rule::exists(Attachment::class, 'id')],
|
||||
|
||||
// 메일 설정
|
||||
'mail.mailer' => $this->getTabRules($tab, 'mail', [Rule::in(self::SUPPORTED_MAILERS)]),
|
||||
'mail.host' => $this->getMailerRules($tab, 'smtp', 'string|max:255'),
|
||||
'mail.port' => $this->getMailerRules($tab, 'smtp', 'integer|min:1|max:65535'),
|
||||
'mail.username' => ['nullable', 'string', 'max:255'],
|
||||
'mail.password' => ['nullable', 'string', 'max:255'],
|
||||
'mail.encryption' => ['nullable', Rule::in(self::SUPPORTED_ENCRYPTIONS)],
|
||||
'mail.mailgun_domain' => $this->getMailerRules($tab, 'mailgun', 'string|max:255'),
|
||||
'mail.mailgun_secret' => $this->getMailerRules($tab, 'mailgun', 'string|max:255'),
|
||||
'mail.mailgun_endpoint' => ['nullable', 'string', 'max:255'],
|
||||
'mail.ses_key' => $this->getMailerRules($tab, 'ses', 'string|max:255'),
|
||||
'mail.ses_secret' => $this->getMailerRules($tab, 'ses', 'string|max:255'),
|
||||
'mail.ses_region' => $this->getMailerRules($tab, 'ses', 'string|max:255'),
|
||||
'mail.from_address' => $this->getTabRules($tab, 'mail', 'email|max:255'),
|
||||
'mail.from_name' => $this->getTabRules($tab, 'mail', 'string|max:255'),
|
||||
|
||||
// 업로드 설정
|
||||
'upload.max_file_size' => $this->getTabRules($tab, 'upload', 'integer|min:1|max:1024'),
|
||||
'upload.allowed_extensions' => $this->getAllowedExtensionsRules($tab),
|
||||
'upload.image_max_width' => ['nullable', 'integer', 'min:100', 'max:10000'],
|
||||
'upload.image_max_height' => ['nullable', 'integer', 'min:100', 'max:10000'],
|
||||
'upload.image_quality' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||
|
||||
// SEO 설정
|
||||
'seo.meta_title_suffix' => ['nullable', 'string', 'max:100'],
|
||||
'seo.meta_description' => ['nullable', 'string', 'max:160'],
|
||||
'seo.meta_keywords' => ['nullable', 'string', 'max:255'],
|
||||
'seo.google_analytics_id' => ['nullable', 'string', 'max:50'],
|
||||
'seo.google_site_verification' => ['nullable', 'string', 'max:100'],
|
||||
'seo.naver_site_verification' => ['nullable', 'string', 'max:100'],
|
||||
'seo.bot_user_agents' => ['nullable', 'array'],
|
||||
'seo.bot_user_agents.*' => ['string', 'max:100'],
|
||||
'seo.bot_detection_enabled' => ['nullable', 'boolean'],
|
||||
'seo.cache_enabled' => ['nullable', 'boolean'],
|
||||
'seo.cache_ttl' => ['nullable', 'integer', 'min:60', 'max:86400'],
|
||||
'seo.sitemap_enabled' => ['nullable', 'boolean'],
|
||||
'seo.sitemap_cache_ttl' => ['nullable', 'integer', 'min:3600', 'max:604800'],
|
||||
'seo.sitemap_schedule' => ['nullable', 'string', Rule::in(['hourly', 'daily', 'weekly'])],
|
||||
'seo.sitemap_schedule_time' => ['nullable', 'string', 'regex:/^\d{2}:\d{2}$/'],
|
||||
|
||||
// 보안 설정
|
||||
'security.force_https' => $this->getTabRules($tab, 'security', 'boolean'),
|
||||
'security.login_attempt_enabled' => $this->getTabRules($tab, 'security', 'boolean'),
|
||||
'security.auth_token_lifetime' => $this->getSecurityTabAuthTokenRules($tab),
|
||||
'security.max_login_attempts' => ['nullable', 'integer', 'min:0', 'max:100'],
|
||||
'security.login_lockout_time' => ['nullable', 'integer', 'min:0', 'max:1440'],
|
||||
|
||||
// 캐시 설정 (advanced 탭)
|
||||
'advanced.cache_enabled' => $this->getTabRules($tab, 'advanced', 'boolean'),
|
||||
'advanced.layout_cache_enabled' => $this->getTabRules($tab, 'advanced', 'boolean'),
|
||||
'advanced.layout_cache_ttl' => $this->getAdvancedTabCacheTtlRules($tab),
|
||||
'advanced.stats_cache_enabled' => $this->getTabRules($tab, 'advanced', 'boolean'),
|
||||
'advanced.stats_cache_ttl' => $this->getAdvancedTabCacheTtlRules($tab),
|
||||
'advanced.seo_cache_enabled' => $this->getTabRules($tab, 'advanced', 'boolean'),
|
||||
'advanced.seo_cache_ttl' => $this->getAdvancedTabCacheTtlRules($tab),
|
||||
|
||||
// 디버그 설정 (advanced 탭)
|
||||
'advanced.debug_mode' => $this->getTabRules($tab, 'advanced', 'boolean'),
|
||||
'advanced.sql_query_log' => $this->getTabRules($tab, 'advanced', 'boolean'),
|
||||
|
||||
// 코어 업데이트 설정 (advanced 탭)
|
||||
'advanced.core_update_github_url' => ['nullable', 'url', 'max:500'],
|
||||
'advanced.core_update_github_token' => ['nullable', 'string', 'max:500'],
|
||||
|
||||
// 드라이버 설정 (drivers 탭)
|
||||
'drivers.storage_driver' => $this->getTabRules($tab, 'drivers', [Rule::in(self::SUPPORTED_STORAGE_DRIVERS)]),
|
||||
'drivers.s3_bucket' => ['nullable', 'string', 'max:255'],
|
||||
'drivers.s3_region' => ['nullable', Rule::in(self::SUPPORTED_S3_REGIONS)],
|
||||
'drivers.s3_access_key' => ['nullable', 'string', 'max:255'],
|
||||
'drivers.s3_secret_key' => ['nullable', 'string', 'max:255'],
|
||||
'drivers.s3_url' => ['nullable', 'url', 'max:500'],
|
||||
'drivers.cache_driver' => $this->getTabRules($tab, 'drivers', [Rule::in(self::SUPPORTED_CACHE_DRIVERS)]),
|
||||
'drivers.redis_host' => ['nullable', 'string', 'max:255'],
|
||||
'drivers.redis_port' => ['nullable', 'integer', 'min:1', 'max:65535'],
|
||||
'drivers.redis_password' => ['nullable', 'string', 'max:255'],
|
||||
'drivers.redis_database' => ['nullable', 'integer', 'min:0', 'max:15'],
|
||||
'drivers.memcached_host' => ['nullable', 'string', 'max:255'],
|
||||
'drivers.memcached_port' => ['nullable', 'integer', 'min:1', 'max:65535'],
|
||||
'drivers.session_driver' => $this->getTabRules($tab, 'drivers', [Rule::in(self::SUPPORTED_SESSION_DRIVERS)]),
|
||||
'drivers.session_lifetime' => ['nullable', 'integer', 'min:1', 'max:43200'], // 1분 ~ 30일
|
||||
'drivers.queue_driver' => $this->getTabRules($tab, 'drivers', [Rule::in(self::SUPPORTED_QUEUE_DRIVERS)]),
|
||||
'drivers.websocket_enabled' => ['nullable', 'boolean'],
|
||||
'drivers.websocket_app_key' => ['nullable', 'string', 'max:255'],
|
||||
'drivers.websocket_host' => ['nullable', 'string', 'max:255'],
|
||||
'drivers.websocket_port' => ['nullable', 'integer', 'min:1', 'max:65535'],
|
||||
'drivers.websocket_scheme' => ['nullable', Rule::in(self::SUPPORTED_WEBSOCKET_SCHEMES)],
|
||||
'drivers.search_engine_driver' => ['nullable', Rule::in($this->getSupportedSearchEngineDrivers())],
|
||||
'drivers.log_driver' => $this->getTabRules($tab, 'drivers', [Rule::in(self::SUPPORTED_LOG_DRIVERS)]),
|
||||
'drivers.log_level' => $this->getTabRules($tab, 'drivers', [Rule::in(self::SUPPORTED_LOG_LEVELS)]),
|
||||
'drivers.log_days' => ['nullable', 'integer', 'min:1', 'max:365'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.settings.save_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 탭의 필수 필드에 대한 규칙을 반환합니다.
|
||||
*
|
||||
* @param string $currentTab 현재 활성 탭
|
||||
* @param string $targetTab 규칙이 적용될 타겟 탭
|
||||
* @param string|array $additionalRules 추가 규칙
|
||||
* @return array 검증 규칙 배열
|
||||
*/
|
||||
private function getTabRules(string $currentTab, string $targetTab, string|array $additionalRules): array
|
||||
{
|
||||
$baseRules = $currentTab === $targetTab ? ['required'] : ['nullable'];
|
||||
|
||||
if (is_string($additionalRules)) {
|
||||
return array_merge($baseRules, explode('|', $additionalRules));
|
||||
}
|
||||
|
||||
return array_merge($baseRules, $additionalRules);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메일러 드라이버별 조건부 필드 규칙을 반환합니다.
|
||||
*
|
||||
* mail 탭이 활성 상태이고 현재 선택된 메일러가 대상 메일러와 일치하면 필수,
|
||||
* 그렇지 않으면 nullable로 처리합니다.
|
||||
*
|
||||
* @param string $currentTab 현재 활성 탭
|
||||
* @param string $targetMailer 규칙이 적용될 대상 메일러 (smtp, mailgun, ses)
|
||||
* @param string|array $additionalRules 추가 규칙
|
||||
* @return array 검증 규칙 배열
|
||||
*/
|
||||
private function getMailerRules(string $currentTab, string $targetMailer, string|array $additionalRules): array
|
||||
{
|
||||
$mailer = $this->input('mail.mailer', 'smtp');
|
||||
$isRequired = $currentTab === 'mail' && $mailer === $targetMailer;
|
||||
$baseRules = $isRequired ? ['required'] : ['nullable'];
|
||||
|
||||
if (is_string($additionalRules)) {
|
||||
return array_merge($baseRules, explode('|', $additionalRules));
|
||||
}
|
||||
|
||||
return array_merge($baseRules, $additionalRules);
|
||||
}
|
||||
|
||||
/**
|
||||
* 인증 토큰 유지시간에 대한 검증 규칙을 반환합니다.
|
||||
* 0이면 무한대, 30~3600 분 사이 값만 허용
|
||||
*
|
||||
* @param string $currentTab 현재 탭
|
||||
* @return array 검증 규칙 배열
|
||||
*/
|
||||
private function getSecurityTabAuthTokenRules(string $currentTab): array
|
||||
{
|
||||
return [
|
||||
'nullable',
|
||||
'integer',
|
||||
'min:0',
|
||||
'max:3600',
|
||||
function ($attribute, $value, $fail) {
|
||||
// 0은 무한대를 의미하므로 허용, 그 외에는 30 이상이어야 함
|
||||
if ($value !== null && $value !== 0 && $value < 30) {
|
||||
$fail(__('validation.settings.auth_token_lifetime_range'));
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 허용 확장자에 대한 검증 규칙을 반환합니다.
|
||||
* 문자열(콤마 구분) 또는 배열 형태 모두 허용합니다.
|
||||
*
|
||||
* @param string $currentTab 현재 탭
|
||||
* @return array 검증 규칙 배열
|
||||
*/
|
||||
private function getAllowedExtensionsRules(string $currentTab): array
|
||||
{
|
||||
$baseRules = $currentTab === 'upload' ? ['required'] : ['nullable'];
|
||||
|
||||
return array_merge($baseRules, [
|
||||
function ($attribute, $value, $fail) {
|
||||
// 배열인 경우
|
||||
if (is_array($value)) {
|
||||
$joined = implode(',', $value);
|
||||
if (strlen($joined) > 500) {
|
||||
$fail(__('validation.settings.allowed_extensions_max'));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 문자열인 경우
|
||||
if (is_string($value)) {
|
||||
if (strlen($value) > 500) {
|
||||
$fail(__('validation.settings.allowed_extensions_max'));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 그 외 타입은 에러
|
||||
$fail(__('validation.settings.allowed_extensions_invalid_type'));
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 캐시 TTL에 대한 검증 규칙을 반환합니다.
|
||||
* 0이면 무한대, 1~14400 초 사이 값만 허용
|
||||
*
|
||||
* @param string $currentTab 현재 탭
|
||||
* @return array 검증 규칙 배열
|
||||
*/
|
||||
private function getAdvancedTabCacheTtlRules(string $currentTab): array
|
||||
{
|
||||
$baseRules = $currentTab === 'advanced' ? ['required'] : ['nullable'];
|
||||
|
||||
return array_merge($baseRules, [
|
||||
'integer',
|
||||
'min:0',
|
||||
'max:14400',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 지원되는 검색엔진 드라이버 목록을 반환합니다.
|
||||
*
|
||||
* 플러그인이 `core.search.engine_drivers` 필터 훅으로 등록한 드라이버를 포함합니다.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
private function getSupportedSearchEngineDrivers(): array
|
||||
{
|
||||
$drivers = HookManager::applyFilters(
|
||||
'core.search.engine_drivers',
|
||||
['mysql-fulltext' => \App\Search\Engines\DatabaseFulltextEngine::class]
|
||||
);
|
||||
|
||||
return array_keys($drivers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* nested 구조에 맞게 'category.field.rule' 형식으로 정의합니다.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
// 일반 설정 - 필수 필드
|
||||
'general.site_name.required' => __('validation.settings.site_name_required'),
|
||||
'general.site_name.max' => __('validation.settings.site_name_max'),
|
||||
'general.site_url.required' => __('validation.settings.site_url_required'),
|
||||
'general.site_url.url' => __('validation.settings.site_url_invalid'),
|
||||
'general.site_url.max' => __('validation.settings.site_url_max'),
|
||||
'general.site_description.max' => __('validation.settings.site_description_max'),
|
||||
'general.admin_email.required' => __('validation.settings.admin_email_required'),
|
||||
'general.admin_email.email' => __('validation.settings.admin_email_invalid'),
|
||||
'general.admin_email.max' => __('validation.settings.admin_email_max'),
|
||||
'general.timezone.required' => __('validation.settings.timezone_required'),
|
||||
'general.timezone.in' => __('validation.settings.timezone_invalid'),
|
||||
'general.language.required' => __('validation.settings.language_required'),
|
||||
'general.language.in' => __('validation.settings.language_invalid'),
|
||||
'general.currency.max' => __('validation.settings.currency_max'),
|
||||
'general.maintenance_mode.boolean' => __('validation.settings.maintenance_mode_boolean'),
|
||||
|
||||
// 메일 설정
|
||||
'mail.mailer.required' => __('validation.settings.mailer_required'),
|
||||
'mail.mailer.in' => __('validation.settings.mailer_invalid'),
|
||||
'mail.host.required' => __('validation.settings.host_required'),
|
||||
'mail.host.max' => __('validation.settings.host_max'),
|
||||
'mail.port.required' => __('validation.settings.port_required'),
|
||||
'mail.port.integer' => __('validation.settings.port_integer'),
|
||||
'mail.port.min' => __('validation.settings.port_min'),
|
||||
'mail.port.max' => __('validation.settings.port_max'),
|
||||
'mail.username.max' => __('validation.settings.username_max'),
|
||||
'mail.password.max' => __('validation.settings.password_max'),
|
||||
'mail.encryption.in' => __('validation.settings.encryption_invalid'),
|
||||
'mail.from_address.required' => __('validation.settings.from_address_required'),
|
||||
'mail.from_address.email' => __('validation.settings.from_address_invalid'),
|
||||
'mail.from_address.max' => __('validation.settings.from_address_max'),
|
||||
'mail.from_name.required' => __('validation.settings.from_name_required'),
|
||||
'mail.from_name.max' => __('validation.settings.from_name_max'),
|
||||
|
||||
// 업로드 설정
|
||||
'upload.max_file_size.required' => __('validation.settings.max_file_size_required'),
|
||||
'upload.max_file_size.integer' => __('validation.settings.max_file_size_integer'),
|
||||
'upload.max_file_size.min' => __('validation.settings.max_file_size_min'),
|
||||
'upload.max_file_size.max' => __('validation.settings.max_file_size_max'),
|
||||
'upload.allowed_extensions.required' => __('validation.settings.allowed_extensions_required'),
|
||||
'upload.allowed_extensions.max' => __('validation.settings.allowed_extensions_max'),
|
||||
'upload.image_max_width.integer' => __('validation.settings.image_max_width_integer'),
|
||||
'upload.image_max_width.min' => __('validation.settings.image_max_width_min'),
|
||||
'upload.image_max_width.max' => __('validation.settings.image_max_width_max'),
|
||||
'upload.image_max_height.integer' => __('validation.settings.image_max_height_integer'),
|
||||
'upload.image_max_height.min' => __('validation.settings.image_max_height_min'),
|
||||
'upload.image_max_height.max' => __('validation.settings.image_max_height_max'),
|
||||
'upload.image_quality.integer' => __('validation.settings.image_quality_integer'),
|
||||
'upload.image_quality.min' => __('validation.settings.image_quality_min'),
|
||||
'upload.image_quality.max' => __('validation.settings.image_quality_max'),
|
||||
|
||||
// SEO 설정
|
||||
'seo.meta_title_suffix.max' => __('validation.settings.meta_title_suffix_max'),
|
||||
'seo.meta_description.max' => __('validation.settings.meta_description_max'),
|
||||
'seo.meta_keywords.max' => __('validation.settings.meta_keywords_max'),
|
||||
'seo.google_analytics_id.max' => __('validation.settings.google_analytics_id_max'),
|
||||
'seo.google_site_verification.max' => __('validation.settings.google_site_verification_max'),
|
||||
'seo.naver_site_verification.max' => __('validation.settings.naver_site_verification_max'),
|
||||
'seo.bot_user_agents.array' => __('validation.settings.bot_user_agents_array'),
|
||||
'seo.bot_user_agents.*.string' => __('validation.settings.bot_user_agents_item_string'),
|
||||
'seo.bot_user_agents.*.max' => __('validation.settings.bot_user_agents_item_max'),
|
||||
'seo.bot_detection_enabled.boolean' => __('validation.settings.bot_detection_enabled_boolean'),
|
||||
'seo.cache_enabled.boolean' => __('validation.settings.seo_cache_enabled_boolean'),
|
||||
'seo.cache_ttl.integer' => __('validation.settings.seo_cache_ttl_integer'),
|
||||
'seo.cache_ttl.min' => __('validation.settings.seo_cache_ttl_min'),
|
||||
'seo.cache_ttl.max' => __('validation.settings.seo_cache_ttl_max'),
|
||||
'seo.sitemap_enabled.boolean' => __('validation.settings.sitemap_enabled_boolean'),
|
||||
'seo.sitemap_cache_ttl.integer' => __('validation.settings.sitemap_cache_ttl_integer'),
|
||||
'seo.sitemap_cache_ttl.min' => __('validation.settings.sitemap_cache_ttl_min'),
|
||||
'seo.sitemap_cache_ttl.max' => __('validation.settings.sitemap_cache_ttl_max'),
|
||||
'seo.sitemap_schedule.in' => __('validation.settings.sitemap_schedule_invalid'),
|
||||
'seo.sitemap_schedule_time.regex' => __('validation.settings.sitemap_schedule_time_invalid'),
|
||||
|
||||
// 보안 설정
|
||||
'security.force_https.required' => __('validation.settings.force_https_required'),
|
||||
'security.force_https.boolean' => __('validation.settings.force_https_boolean'),
|
||||
'security.login_attempt_enabled.required' => __('validation.settings.login_attempt_enabled_required'),
|
||||
'security.login_attempt_enabled.boolean' => __('validation.settings.login_attempt_enabled_boolean'),
|
||||
'security.auth_token_lifetime.integer' => __('validation.settings.auth_token_lifetime_integer'),
|
||||
'security.auth_token_lifetime.min' => __('validation.settings.auth_token_lifetime_min'),
|
||||
'security.auth_token_lifetime.max' => __('validation.settings.auth_token_lifetime_max'),
|
||||
'security.max_login_attempts.integer' => __('validation.settings.max_login_attempts_integer'),
|
||||
'security.max_login_attempts.min' => __('validation.settings.max_login_attempts_min'),
|
||||
'security.max_login_attempts.max' => __('validation.settings.max_login_attempts_max'),
|
||||
'security.login_lockout_time.integer' => __('validation.settings.login_lockout_time_integer'),
|
||||
'security.login_lockout_time.min' => __('validation.settings.login_lockout_time_min'),
|
||||
'security.login_lockout_time.max' => __('validation.settings.login_lockout_time_max'),
|
||||
|
||||
// 캐시 설정
|
||||
'advanced.cache_enabled.required' => __('validation.settings.cache_enabled_required'),
|
||||
'advanced.cache_enabled.boolean' => __('validation.settings.cache_enabled_boolean'),
|
||||
'advanced.layout_cache_enabled.required' => __('validation.settings.layout_cache_enabled_required'),
|
||||
'advanced.layout_cache_enabled.boolean' => __('validation.settings.layout_cache_enabled_boolean'),
|
||||
'advanced.layout_cache_ttl.required' => __('validation.settings.layout_cache_ttl_required'),
|
||||
'advanced.layout_cache_ttl.integer' => __('validation.settings.layout_cache_ttl_integer'),
|
||||
'advanced.layout_cache_ttl.min' => __('validation.settings.layout_cache_ttl_min'),
|
||||
'advanced.layout_cache_ttl.max' => __('validation.settings.layout_cache_ttl_max'),
|
||||
'advanced.stats_cache_enabled.required' => __('validation.settings.stats_cache_enabled_required'),
|
||||
'advanced.stats_cache_enabled.boolean' => __('validation.settings.stats_cache_enabled_boolean'),
|
||||
'advanced.stats_cache_ttl.required' => __('validation.settings.stats_cache_ttl_required'),
|
||||
'advanced.stats_cache_ttl.integer' => __('validation.settings.stats_cache_ttl_integer'),
|
||||
'advanced.stats_cache_ttl.min' => __('validation.settings.stats_cache_ttl_min'),
|
||||
'advanced.stats_cache_ttl.max' => __('validation.settings.stats_cache_ttl_max'),
|
||||
'advanced.seo_cache_enabled.required' => __('validation.settings.seo_cache_enabled_required'),
|
||||
'advanced.seo_cache_enabled.boolean' => __('validation.settings.seo_cache_enabled_boolean'),
|
||||
'advanced.seo_cache_ttl.required' => __('validation.settings.seo_cache_ttl_required'),
|
||||
'advanced.seo_cache_ttl.integer' => __('validation.settings.seo_cache_ttl_integer'),
|
||||
'advanced.seo_cache_ttl.min' => __('validation.settings.seo_cache_ttl_min'),
|
||||
'advanced.seo_cache_ttl.max' => __('validation.settings.seo_cache_ttl_max'),
|
||||
|
||||
// 디버그 설정
|
||||
'advanced.debug_mode.required' => __('validation.settings.debug_mode_required'),
|
||||
'advanced.debug_mode.boolean' => __('validation.settings.debug_mode_boolean'),
|
||||
'advanced.sql_query_log.required' => __('validation.settings.sql_query_log_required'),
|
||||
'advanced.sql_query_log.boolean' => __('validation.settings.sql_query_log_boolean'),
|
||||
|
||||
// 코어 업데이트 설정
|
||||
'advanced.core_update_github_url.url' => __('validation.settings.core_update_github_url_invalid'),
|
||||
'advanced.core_update_github_url.max' => __('validation.settings.core_update_github_url_max'),
|
||||
'advanced.core_update_github_token.max' => __('validation.settings.core_update_github_token_max'),
|
||||
|
||||
// 드라이버 설정
|
||||
'drivers.storage_driver.required' => __('validation.settings.storage_driver_required'),
|
||||
'drivers.storage_driver.in' => __('validation.settings.storage_driver_invalid'),
|
||||
'drivers.s3_bucket.max' => __('validation.settings.s3_bucket_max'),
|
||||
'drivers.s3_region.in' => __('validation.settings.s3_region_invalid'),
|
||||
'drivers.s3_access_key.max' => __('validation.settings.s3_access_key_max'),
|
||||
'drivers.s3_secret_key.max' => __('validation.settings.s3_secret_key_max'),
|
||||
'drivers.s3_url.url' => __('validation.settings.s3_url_invalid'),
|
||||
'drivers.s3_url.max' => __('validation.settings.s3_url_max'),
|
||||
'drivers.cache_driver.required' => __('validation.settings.cache_driver_required'),
|
||||
'drivers.cache_driver.in' => __('validation.settings.cache_driver_invalid'),
|
||||
'drivers.redis_host.max' => __('validation.settings.redis_host_max'),
|
||||
'drivers.redis_port.integer' => __('validation.settings.redis_port_integer'),
|
||||
'drivers.redis_port.min' => __('validation.settings.redis_port_min'),
|
||||
'drivers.redis_port.max' => __('validation.settings.redis_port_max'),
|
||||
'drivers.redis_password.max' => __('validation.settings.redis_password_max'),
|
||||
'drivers.redis_database.integer' => __('validation.settings.redis_database_integer'),
|
||||
'drivers.redis_database.min' => __('validation.settings.redis_database_min'),
|
||||
'drivers.redis_database.max' => __('validation.settings.redis_database_max'),
|
||||
'drivers.memcached_host.max' => __('validation.settings.memcached_host_max'),
|
||||
'drivers.memcached_port.integer' => __('validation.settings.memcached_port_integer'),
|
||||
'drivers.memcached_port.min' => __('validation.settings.memcached_port_min'),
|
||||
'drivers.memcached_port.max' => __('validation.settings.memcached_port_max'),
|
||||
'drivers.session_driver.required' => __('validation.settings.session_driver_required'),
|
||||
'drivers.session_driver.in' => __('validation.settings.session_driver_invalid'),
|
||||
'drivers.session_lifetime.integer' => __('validation.settings.session_lifetime_integer'),
|
||||
'drivers.session_lifetime.min' => __('validation.settings.session_lifetime_min'),
|
||||
'drivers.session_lifetime.max' => __('validation.settings.session_lifetime_max'),
|
||||
'drivers.queue_driver.required' => __('validation.settings.queue_driver_required'),
|
||||
'drivers.queue_driver.in' => __('validation.settings.queue_driver_invalid'),
|
||||
'drivers.websocket_enabled.boolean' => __('validation.settings.websocket_enabled_boolean'),
|
||||
'drivers.websocket_app_key.max' => __('validation.settings.websocket_app_key_max'),
|
||||
'drivers.websocket_host.max' => __('validation.settings.websocket_host_max'),
|
||||
'drivers.websocket_port.integer' => __('validation.settings.websocket_port_integer'),
|
||||
'drivers.websocket_port.min' => __('validation.settings.websocket_port_min'),
|
||||
'drivers.websocket_port.max' => __('validation.settings.websocket_port_max'),
|
||||
'drivers.websocket_scheme.in' => __('validation.settings.websocket_scheme_invalid'),
|
||||
'drivers.search_engine_driver.in' => __('validation.settings.search_engine_driver_invalid'),
|
||||
'drivers.log_driver.required' => __('validation.settings.log_driver_required'),
|
||||
'drivers.log_driver.in' => __('validation.settings.log_driver_invalid'),
|
||||
'drivers.log_level.required' => __('validation.settings.log_level_required'),
|
||||
'drivers.log_level.in' => __('validation.settings.log_level_invalid'),
|
||||
'drivers.log_days.integer' => __('validation.settings.log_days_integer'),
|
||||
'drivers.log_days.min' => __('validation.settings.log_days_min'),
|
||||
'drivers.log_days.max' => __('validation.settings.log_days_max'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* nested 구조에 맞게 'category.field' 형식으로 정의합니다.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'general.site_name' => __('validation.attributes.site_name'),
|
||||
'general.site_url' => __('validation.attributes.site_url'),
|
||||
'general.site_description' => __('validation.attributes.site_description'),
|
||||
'general.admin_email' => __('validation.attributes.admin_email'),
|
||||
'general.timezone' => __('validation.attributes.timezone'),
|
||||
'general.language' => __('validation.attributes.language'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Settings;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 드라이버 연결 테스트 요청 검증
|
||||
*
|
||||
* S3, Redis, Memcached, Websocket 드라이버 연결 테스트에 필요한
|
||||
* 설정값을 검증합니다.
|
||||
*/
|
||||
class TestDriverConnectionRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 지원되는 스토리지 드라이버 목록
|
||||
*/
|
||||
private const SUPPORTED_STORAGE_DRIVERS = ['local', 's3'];
|
||||
|
||||
/**
|
||||
* 지원되는 S3 리전 목록
|
||||
*/
|
||||
private const SUPPORTED_S3_REGIONS = ['ap-northeast-2', 'ap-northeast-1', 'us-east-1', 'us-west-2', 'eu-west-1'];
|
||||
|
||||
/**
|
||||
* 지원되는 캐시 드라이버 목록
|
||||
*/
|
||||
private const SUPPORTED_CACHE_DRIVERS = ['file', 'redis', 'memcached'];
|
||||
|
||||
/**
|
||||
* 지원되는 세션 드라이버 목록
|
||||
*/
|
||||
private const SUPPORTED_SESSION_DRIVERS = ['file', 'database', 'redis'];
|
||||
|
||||
/**
|
||||
* 지원되는 큐 드라이버 목록
|
||||
*/
|
||||
private const SUPPORTED_QUEUE_DRIVERS = ['sync', 'database', 'redis'];
|
||||
|
||||
/**
|
||||
* 지원되는 웹소켓 프로토콜 목록
|
||||
*/
|
||||
private const SUPPORTED_WEBSOCKET_SCHEMES = ['http', 'https'];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
// 드라이버 선택
|
||||
'storage_driver' => ['nullable', Rule::in(self::SUPPORTED_STORAGE_DRIVERS)],
|
||||
'cache_driver' => ['nullable', Rule::in(self::SUPPORTED_CACHE_DRIVERS)],
|
||||
'session_driver' => ['nullable', Rule::in(self::SUPPORTED_SESSION_DRIVERS)],
|
||||
'queue_driver' => ['nullable', Rule::in(self::SUPPORTED_QUEUE_DRIVERS)],
|
||||
'websocket_enabled' => ['nullable', 'boolean'],
|
||||
|
||||
// S3 설정
|
||||
's3_bucket' => ['nullable', 'string', 'max:255'],
|
||||
's3_region' => ['nullable', Rule::in(self::SUPPORTED_S3_REGIONS)],
|
||||
's3_access_key' => ['nullable', 'string', 'max:255'],
|
||||
's3_secret_key' => ['nullable', 'string', 'max:255'],
|
||||
's3_url' => ['nullable', 'url', 'max:500'],
|
||||
|
||||
// Redis 설정
|
||||
'redis_host' => ['nullable', 'string', 'max:255'],
|
||||
'redis_port' => ['nullable', 'integer', 'min:1', 'max:65535'],
|
||||
'redis_password' => ['nullable', 'string', 'max:255'],
|
||||
'redis_database' => ['nullable', 'integer', 'min:0', 'max:15'],
|
||||
|
||||
// Memcached 설정
|
||||
'memcached_host' => ['nullable', 'string', 'max:255'],
|
||||
'memcached_port' => ['nullable', 'integer', 'min:1', 'max:65535'],
|
||||
|
||||
// Websocket 설정
|
||||
'websocket_app_key' => ['nullable', 'string', 'max:255'],
|
||||
'websocket_host' => ['nullable', 'string', 'max:255'],
|
||||
'websocket_port' => ['nullable', 'integer', 'min:1', 'max:65535'],
|
||||
'websocket_scheme' => ['nullable', Rule::in(self::SUPPORTED_WEBSOCKET_SCHEMES)],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.settings.test_driver_connection_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'storage_driver.in' => __('validation.settings.storage_driver_invalid'),
|
||||
's3_bucket.max' => __('validation.settings.s3_bucket_max'),
|
||||
's3_region.in' => __('validation.settings.s3_region_invalid'),
|
||||
's3_access_key.max' => __('validation.settings.s3_access_key_max'),
|
||||
's3_secret_key.max' => __('validation.settings.s3_secret_key_max'),
|
||||
's3_url.url' => __('validation.settings.s3_url_invalid'),
|
||||
's3_url.max' => __('validation.settings.s3_url_max'),
|
||||
'cache_driver.in' => __('validation.settings.cache_driver_invalid'),
|
||||
'redis_host.max' => __('validation.settings.redis_host_max'),
|
||||
'redis_port.integer' => __('validation.settings.redis_port_integer'),
|
||||
'redis_port.min' => __('validation.settings.redis_port_min'),
|
||||
'redis_port.max' => __('validation.settings.redis_port_max'),
|
||||
'redis_password.max' => __('validation.settings.redis_password_max'),
|
||||
'redis_database.integer' => __('validation.settings.redis_database_integer'),
|
||||
'redis_database.min' => __('validation.settings.redis_database_min'),
|
||||
'redis_database.max' => __('validation.settings.redis_database_max'),
|
||||
'memcached_host.max' => __('validation.settings.memcached_host_max'),
|
||||
'memcached_port.integer' => __('validation.settings.memcached_port_integer'),
|
||||
'memcached_port.min' => __('validation.settings.memcached_port_min'),
|
||||
'memcached_port.max' => __('validation.settings.memcached_port_max'),
|
||||
'session_driver.in' => __('validation.settings.session_driver_invalid'),
|
||||
'queue_driver.in' => __('validation.settings.queue_driver_invalid'),
|
||||
'websocket_enabled.boolean' => __('validation.settings.websocket_enabled_boolean'),
|
||||
'websocket_app_key.max' => __('validation.settings.websocket_app_key_max'),
|
||||
'websocket_host.max' => __('validation.settings.websocket_host_max'),
|
||||
'websocket_port.integer' => __('validation.settings.websocket_port_integer'),
|
||||
'websocket_port.min' => __('validation.settings.websocket_port_min'),
|
||||
'websocket_port.max' => __('validation.settings.websocket_port_max'),
|
||||
'websocket_scheme.in' => __('validation.settings.websocket_scheme_invalid'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Settings;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 테스트 메일 발송 요청 FormRequest
|
||||
*
|
||||
* 테스트 메일 발송 시 이메일 주소 검증을 위한 요청 클래스입니다.
|
||||
*/
|
||||
class TestMailRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*
|
||||
* @return bool 항상 true (미들웨어에서 권한 제어)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$mailer = $this->input('mailer', 'smtp');
|
||||
|
||||
$rules = [
|
||||
'to_email' => ['required', 'email', 'max:255'],
|
||||
'mailer' => ['sometimes', 'string', 'in:smtp,mailgun,ses'],
|
||||
'from_address' => ['required', 'email', 'max:255'],
|
||||
'from_name' => ['required', 'string', 'max:255'],
|
||||
|
||||
// SMTP 필드 (mailer가 smtp일 때만 필수)
|
||||
'host' => $mailer === 'smtp' ? ['required', 'string', 'max:255'] : ['sometimes', 'nullable', 'string', 'max:255'],
|
||||
'port' => $mailer === 'smtp' ? ['required', 'integer', 'min:1', 'max:65535'] : ['sometimes', 'nullable', 'integer', 'min:1', 'max:65535'],
|
||||
'username' => ['sometimes', 'nullable', 'string', 'max:255'],
|
||||
'password' => ['sometimes', 'nullable', 'string', 'max:255'],
|
||||
'encryption' => ['sometimes', 'nullable', 'string', 'in:tls,ssl,null'],
|
||||
|
||||
// Mailgun 필드 (mailer가 mailgun일 때만 필수)
|
||||
'mailgun_domain' => $mailer === 'mailgun' ? ['required', 'string', 'max:255'] : ['sometimes', 'nullable', 'string', 'max:255'],
|
||||
'mailgun_secret' => $mailer === 'mailgun' ? ['required', 'string', 'max:255'] : ['sometimes', 'nullable', 'string', 'max:255'],
|
||||
'mailgun_endpoint' => ['sometimes', 'nullable', 'string', 'max:255'],
|
||||
|
||||
// SES 필드 (mailer가 ses일 때만 필수)
|
||||
'ses_key' => $mailer === 'ses' ? ['required', 'string', 'max:255'] : ['sometimes', 'nullable', 'string', 'max:255'],
|
||||
'ses_secret' => $mailer === 'ses' ? ['required', 'string', 'max:255'] : ['sometimes', 'nullable', 'string', 'max:255'],
|
||||
'ses_region' => $mailer === 'ses' ? ['required', 'string', 'max:255'] : ['sometimes', 'nullable', 'string', 'max:255'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.settings.test_mail_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'to_email.required' => __('settings.invalid_email'),
|
||||
'to_email.email' => __('settings.invalid_email'),
|
||||
'to_email.max' => __('settings.invalid_email'),
|
||||
'from_address.required' => __('validation.required', ['attribute' => __('validation.attributes.from_address')]),
|
||||
'from_name.required' => __('validation.required', ['attribute' => __('validation.attributes.from_name')]),
|
||||
'host.required' => __('validation.required', ['attribute' => __('validation.attributes.host')]),
|
||||
'port.required' => __('validation.required', ['attribute' => __('validation.attributes.port')]),
|
||||
'mailgun_domain.required' => __('validation.required', ['attribute' => __('validation.attributes.mailgun_domain')]),
|
||||
'mailgun_secret.required' => __('validation.required', ['attribute' => __('validation.attributes.mailgun_secret')]),
|
||||
'ses_key.required' => __('validation.required', ['attribute' => __('validation.attributes.ses_key')]),
|
||||
'ses_secret.required' => __('validation.required', ['attribute' => __('validation.attributes.ses_secret')]),
|
||||
'ses_region.required' => __('validation.required', ['attribute' => __('validation.attributes.ses_region')]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Settings;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateSettingRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'value' => 'required|string|max:1000',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.settings.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'value.required' => __('validation.setting.value.required'),
|
||||
'value.string' => __('validation.setting.value.string'),
|
||||
'value.max' => __('validation.setting.value.max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Template;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 템플릿 활성화 요청
|
||||
*/
|
||||
class ActivateTemplateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'template_name' => 'required|string|max:255',
|
||||
'force' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.template.activate_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'template_name.required' => __('templates.validation.name_required'),
|
||||
'template_name.string' => __('templates.validation.name_string'),
|
||||
'template_name.max' => __('templates.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Template;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 템플릿 비활성화 요청
|
||||
*/
|
||||
class DeactivateTemplateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'template_name' => 'required|string|max:255',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.template.deactivate_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'template_name.required' => __('templates.validation.name_required'),
|
||||
'template_name.string' => __('templates.validation.name_string'),
|
||||
'template_name.max' => __('templates.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Template;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 템플릿 목록 조회 요청
|
||||
*
|
||||
* 다중 검색 조건을 지원합니다.
|
||||
* - search: 단일 검색어 (이름, 식별자, 설명, 벤더 OR 검색) - 하위 호환성
|
||||
* - filters: 다중 검색 조건 (AND 조건)
|
||||
* - type: 템플릿 타입 (admin, user)
|
||||
*/
|
||||
class IndexTemplateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 검색 가능한 필드 목록
|
||||
*/
|
||||
public const SEARCHABLE_FIELDS = ['name', 'identifier', 'description', 'vendor'];
|
||||
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$searchableFields = implode(',', self::SEARCHABLE_FIELDS);
|
||||
|
||||
$rules = [
|
||||
// 템플릿 타입 필터
|
||||
'type' => 'nullable|string|in:user,admin',
|
||||
|
||||
// 단일 검색어 (하위 호환성 - 이름, 식별자, 설명, 벤더 OR 검색)
|
||||
'search' => 'nullable|string|max:255',
|
||||
|
||||
// 다중 검색 조건
|
||||
'filters' => 'nullable|array|max:10',
|
||||
'filters.*.field' => "required_with:filters|string|in:{$searchableFields}",
|
||||
'filters.*.value' => 'required_with:filters|string|max:255',
|
||||
'filters.*.operator' => 'nullable|string|in:like,eq,starts_with,ends_with',
|
||||
|
||||
// 상태 필터
|
||||
'status' => 'nullable|string|in:installed,not_installed,active,inactive',
|
||||
|
||||
// 페이지네이션
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.template.index_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'type.in' => __('templates.validation.type_in'),
|
||||
'search.max' => __('templates.validation.search_max'),
|
||||
'filters.max' => __('templates.validation.filters_max'),
|
||||
'filters.*.field.required_with' => __('templates.validation.filter_field_required'),
|
||||
'filters.*.field.in' => __('templates.validation.filter_field_invalid'),
|
||||
'filters.*.value.required_with' => __('templates.validation.filter_value_required'),
|
||||
'filters.*.value.max' => __('templates.validation.filter_value_max'),
|
||||
'filters.*.operator.in' => __('templates.validation.filter_operator_invalid'),
|
||||
'status.in' => __('templates.validation.status_invalid'),
|
||||
'per_page.min' => __('templates.validation.per_page_min'),
|
||||
'per_page.max' => __('templates.validation.per_page_max'),
|
||||
'page.min' => __('templates.validation.page_min'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Template;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 파일에서 템플릿 설치 요청
|
||||
*/
|
||||
class InstallTemplateFromFileRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$maxSize = config('template.upload_max_size', 50) * 1024; // MB를 KB로 변환
|
||||
|
||||
$rules = [
|
||||
'file' => [
|
||||
'required',
|
||||
'file',
|
||||
'mimes:zip',
|
||||
'max:'.$maxSize,
|
||||
],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.template.install_from_file_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
$maxSize = config('template.upload_max_size', 50);
|
||||
|
||||
return [
|
||||
'file.required' => __('templates.validation.file_required'),
|
||||
'file.file' => __('templates.validation.file_invalid'),
|
||||
'file.mimes' => __('templates.validation.file_must_be_zip'),
|
||||
'file.max' => __('templates.validation.file_max_size', ['size' => $maxSize]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Template;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* GitHub에서 템플릿 설치 요청
|
||||
*/
|
||||
class InstallTemplateFromGithubRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'github_url' => [
|
||||
'required',
|
||||
'url',
|
||||
'regex:/^https?:\/\/(www\.)?github\.com\/[a-zA-Z0-9\-_]+\/[a-zA-Z0-9\-_]+\/?$/',
|
||||
],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.template.install_from_github_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'github_url.required' => __('templates.validation.github_url_required'),
|
||||
'github_url.url' => __('templates.validation.github_url_invalid'),
|
||||
'github_url.regex' => __('templates.validation.github_url_format'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Template;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Rules\ValidExtensionIdentifier;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 템플릿 설치 요청
|
||||
*/
|
||||
class InstallTemplateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'template_name' => ['required', 'string', 'max:255', new ValidExtensionIdentifier],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.template.install_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'template_name.required' => __('templates.validation.name_required'),
|
||||
'template_name.string' => __('templates.validation.name_string'),
|
||||
'template_name.max' => __('templates.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Template;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 템플릿 업데이트 실행 요청 검증
|
||||
*
|
||||
* layout_strategy: 레이아웃 전략 (overwrite 또는 keep)
|
||||
*/
|
||||
class PerformTemplateUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'layout_strategy' => ['nullable', 'string', 'in:overwrite,keep'],
|
||||
];
|
||||
|
||||
return HookManager::applyFilters('core.template.perform_update_rules', $rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'layout_strategy.in' => __('templates.errors.invalid_layout_strategy'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Template;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RefreshTemplateLayoutsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'template_name' => 'required|string|max:255',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.template.refresh_layouts_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'template_name.required' => __('templates.validation.name_required'),
|
||||
'template_name.string' => __('templates.validation.name_string'),
|
||||
'template_name.max' => __('templates.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Template;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 템플릿 제거 요청
|
||||
*/
|
||||
class UninstallTemplateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'template_name' => 'required|string|max:255',
|
||||
'delete_data' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.template.uninstall_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'template_name.required' => __('templates.validation.name_required'),
|
||||
'template_name.string' => __('templates.validation.name_string'),
|
||||
'template_name.max' => __('templates.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Template;
|
||||
|
||||
use App\Enums\ExtensionStatus;
|
||||
use App\Extension\HookManager;
|
||||
use App\Rules\TranslatableField;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 템플릿 업데이트 요청 검증
|
||||
*
|
||||
* 템플릿의 name, description, metadata 등을 업데이트할 수 있습니다.
|
||||
* name과 description은 다국어 필드로 처리됩니다.
|
||||
*/
|
||||
class UpdateTemplateRequest 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)],
|
||||
'metadata' => 'nullable|array',
|
||||
'status' => ['nullable', 'string', Rule::in(ExtensionStatus::values())],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.template.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.max' => __('validation.template.name.max'),
|
||||
'description.max' => __('validation.template.description.max'),
|
||||
'metadata.array' => __('validation.template.metadata.array'),
|
||||
'status.in' => __('validation.template.status.in'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Enums\UserStatus;
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\User;
|
||||
use App\Rules\ExcludeCurrentUser;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class BulkUpdateUserStatusRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한을 확인합니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
// 사용자 업데이트 권한 확인
|
||||
return $this->user()->can('core.users.update');
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 규칙을 정의합니다.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'ids' => ['required', 'array', 'min:1', new ExcludeCurrentUser],
|
||||
'ids.*' => ['required', 'uuid', Rule::exists(User::class, 'uuid')],
|
||||
'status' => ['required', 'string', Rule::in(UserStatus::values())],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.user.bulk_update_status_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지를 정의합니다.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'ids.required' => __('validation.required', ['attribute' => __('validation.attributes.ids')]),
|
||||
'ids.array' => __('validation.array', ['attribute' => __('validation.attributes.ids')]),
|
||||
'ids.min' => __('validation.min.array', ['attribute' => __('validation.attributes.ids'), 'min' => 1]),
|
||||
'ids.*.required' => __('validation.required', ['attribute' => __('validation.attributes.user_id')]),
|
||||
'ids.*.uuid' => __('validation.uuid', ['attribute' => __('validation.attributes.user_id')]),
|
||||
'ids.*.exists' => __('validation.exists', ['attribute' => __('validation.attributes.user_id')]),
|
||||
'status.required' => __('validation.required', ['attribute' => __('validation.attributes.status')]),
|
||||
'status.in' => __('validation.in', ['attribute' => __('validation.attributes.status')]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
/**
|
||||
* 비밀번호 변경 요청 클래스
|
||||
*
|
||||
* 사용자가 자신의 비밀번호를 변경할 때 사용되는 validation 규칙을 정의합니다.
|
||||
*/
|
||||
class ChangePasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'current_password' => ['required', 'string', 'current_password:sanctum'],
|
||||
'password' => ['required', 'string', 'confirmed', Password::min(8)],
|
||||
'password_confirmation' => ['required', 'string'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.user.change_password_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'current_password.required' => __('user.validation.current_password_required'),
|
||||
'current_password.current_password' => __('user.validation.current_password_invalid'),
|
||||
'password.required' => __('user.validation.password_required'),
|
||||
'password.confirmed' => __('user.validation.password_confirmed'),
|
||||
'password.min' => __('user.validation.password_min'),
|
||||
'password_confirmation.required' => __('user.validation.password_confirmation_required'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 이메일 중복 확인 요청 검증
|
||||
*/
|
||||
class CheckEmailRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'email' => 'required|email|max:255',
|
||||
'exclude_user_id' => ['nullable', 'uuid', Rule::exists(User::class, 'uuid')],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.user.check_email_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'email.required' => __('user.validation.email_required'),
|
||||
'email.email' => __('user.validation.email_invalid'),
|
||||
'email.max' => __('user.validation.email_max'),
|
||||
'exclude_user_id.uuid' => __('user.validation.exclude_user_id_uuid'),
|
||||
'exclude_user_id.exists' => __('user.validation.exclude_user_id_exists'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class CreateUserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$supportedLocales = implode(',', config('app.supported_locales', ['ko', 'en']));
|
||||
|
||||
$rules = [
|
||||
// 기본 정보
|
||||
'name' => 'required|string|max:255',
|
||||
'nickname' => 'nullable|string|max:50',
|
||||
'email' => ['required', 'email', Rule::unique(User::class, 'email'), 'max:255'],
|
||||
'password' => ['required', 'confirmed', Password::min(8)],
|
||||
'language' => 'nullable|string|in:'.$supportedLocales,
|
||||
'country' => 'nullable|string|size:2|alpha',
|
||||
'timezone' => ['nullable', 'string', Rule::in(config('app.supported_timezones', ['Asia/Seoul']))],
|
||||
'status' => 'nullable|string|in:active,inactive,blocked,withdrawn',
|
||||
|
||||
// 연락처 정보
|
||||
'homepage' => 'nullable|url|max:255',
|
||||
'mobile' => ['nullable', 'string', 'max:20', 'regex:/^[0-9\-\+\(\)\s]+$/'],
|
||||
'phone' => ['nullable', 'string', 'max:20', 'regex:/^[0-9\-\+\(\)\s]+$/'],
|
||||
|
||||
// 주소 정보
|
||||
'zipcode' => 'nullable|string|max:10',
|
||||
'address' => 'nullable|string|max:255',
|
||||
'address_detail' => 'nullable|string|max:255',
|
||||
|
||||
// 추가 정보
|
||||
'signature' => 'nullable|string|max:1000',
|
||||
'bio' => 'nullable|string|max:5000',
|
||||
'admin_memo' => 'nullable|string|max:5000',
|
||||
|
||||
// 역할 정보 (객체 배열 또는 id 배열 모두 허용, 하나 이상 필수)
|
||||
'roles' => 'required_without:role_ids|array|min:1',
|
||||
'roles.*.id' => ['required', 'integer', Rule::exists(Role::class, 'id')],
|
||||
'role_ids' => 'required_without:roles|array|min:1',
|
||||
'role_ids.*' => ['integer', Rule::exists(Role::class, 'id')],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.user.create_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
// 기본 정보
|
||||
'name.required' => __('user.validation.name_required'),
|
||||
'name.string' => __('user.validation.name_string'),
|
||||
'name.max' => __('user.validation.name_max'),
|
||||
'nickname.string' => __('user.validation.nickname_string'),
|
||||
'nickname.max' => __('user.validation.nickname_max'),
|
||||
'email.required' => __('user.validation.email_required'),
|
||||
'email.email' => __('user.validation.email_invalid'),
|
||||
'email.unique' => __('user.validation.email_unique'),
|
||||
'email.max' => __('user.validation.email_max'),
|
||||
'password.required' => __('user.validation.password_required'),
|
||||
'password.confirmed' => __('user.validation.password_confirmed'),
|
||||
'password.min' => __('user.validation.password_min'),
|
||||
'language.in' => __('user.validation.language_invalid'),
|
||||
'country.size' => __('user.validation.country_size'),
|
||||
'country.alpha' => __('user.validation.country_alpha'),
|
||||
'timezone.in' => __('user.validation.timezone_invalid'),
|
||||
'status.in' => __('user.validation.status_invalid'),
|
||||
|
||||
// 연락처 정보
|
||||
'homepage.url' => __('user.validation.homepage_url'),
|
||||
'homepage.max' => __('user.validation.homepage_max'),
|
||||
'mobile.max' => __('user.validation.mobile_max'),
|
||||
'mobile.regex' => __('user.validation.mobile_regex'),
|
||||
'phone.max' => __('user.validation.phone_max'),
|
||||
'phone.regex' => __('user.validation.phone_regex'),
|
||||
|
||||
// 주소 정보
|
||||
'zipcode.max' => __('user.validation.zipcode_max'),
|
||||
'address.max' => __('user.validation.address_max'),
|
||||
'address_detail.max' => __('user.validation.address_detail_max'),
|
||||
|
||||
// 추가 정보
|
||||
'signature.max' => __('user.validation.signature_max'),
|
||||
'bio.max' => __('user.validation.bio_max'),
|
||||
'admin_memo.max' => __('user.validation.admin_memo_max'),
|
||||
|
||||
// 역할 정보
|
||||
'roles.required_without' => __('user.validation.roles_required'),
|
||||
'roles.min' => __('user.validation.roles_min'),
|
||||
'role_ids.required_without' => __('user.validation.roles_required'),
|
||||
'role_ids.min' => __('user.validation.roles_min'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 유효성 검사를 위해 데이터를 준비합니다.
|
||||
*
|
||||
* role_ids와 roles가 동시에 전송될 경우 role_ids를 우선하여 roles를 제거합니다.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->has('role_ids') && $this->has('roles')) {
|
||||
$this->getInputSource()->remove('roles');
|
||||
}
|
||||
|
||||
$this->merge([
|
||||
'language' => $this->language ?? 'ko',
|
||||
'status' => $this->status ?? 'active',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DeleteUserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
// 추가 검증이 필요한 경우 여기에 추가
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.user.delete_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
// 메시지가 필요한 경우 여기에 추가
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 사용자 검색 요청 검증
|
||||
*/
|
||||
class SearchUserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'keyword' => 'required_without:uuid|string|max:255',
|
||||
'uuid' => ['required_without:keyword', 'uuid', Rule::exists(User::class, 'uuid')],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.user.search_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'keyword.required_without' => __('user.validation.search_keyword_required'),
|
||||
'keyword.string' => __('user.validation.name_string'),
|
||||
'keyword.max' => __('user.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateLanguageRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$supportedLocales = implode(',', config('app.supported_locales', ['ko', 'en']));
|
||||
|
||||
$rules = [
|
||||
'language' => 'required|string|in:' . $supportedLocales,
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.user.update_language_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'language.required' => __('user.validation.language_required'),
|
||||
'language.string' => __('user.validation.language_string'),
|
||||
'language.in' => __('user.validation.language_invalid'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
/**
|
||||
* 사용자 프로필 업데이트 요청 클래스
|
||||
*
|
||||
* 일반 사용자가 자신의 프로필 정보를 수정할 때 사용되는 validation 규칙을 정의합니다.
|
||||
* 관리자용 UpdateUserRequest와 달리 사용자 본인만 수정할 수 있는 필드들로 제한됩니다.
|
||||
*/
|
||||
class UpdateProfileRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$userId = Auth::id();
|
||||
$supportedLocales = config('app.supported_locales', ['ko', 'en']);
|
||||
|
||||
$rules = [
|
||||
// 기본 정보
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'nickname' => ['nullable', 'string', 'max:50'],
|
||||
'email' => ['required', 'email', 'max:255', Rule::unique(User::class, 'email')->ignore($userId)],
|
||||
'password' => ['nullable', 'confirmed', Password::min(8)],
|
||||
'current_password' => ['required_with:password', 'current_password'],
|
||||
'language' => ['nullable', 'string', Rule::in($supportedLocales)],
|
||||
'country' => ['nullable', 'string', 'size:2', 'alpha'],
|
||||
'timezone' => ['nullable', 'string', Rule::in(config('app.supported_timezones', ['Asia/Seoul']))],
|
||||
|
||||
// 연락처 정보
|
||||
'homepage' => ['nullable', 'url', 'max:255'],
|
||||
'mobile' => ['nullable', 'string', 'max:20', 'regex:/^[0-9\-\+\(\)\s]+$/'],
|
||||
'phone' => ['nullable', 'string', 'max:20', 'regex:/^[0-9\-\+\(\)\s]+$/'],
|
||||
|
||||
// 주소 정보
|
||||
'zipcode' => ['nullable', 'string', 'max:10'],
|
||||
'address' => ['nullable', 'string', 'max:255'],
|
||||
'address_detail' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
// 추가 정보
|
||||
'signature' => ['nullable', 'string', 'max:1000'],
|
||||
'bio' => ['nullable', 'string', 'max:5000'],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.user.update_profile_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
// 기본 정보
|
||||
'name.required' => __('user.validation.name_required'),
|
||||
'name.string' => __('user.validation.name_string'),
|
||||
'name.max' => __('user.validation.name_max'),
|
||||
'nickname.string' => __('user.validation.nickname_string'),
|
||||
'nickname.max' => __('user.validation.nickname_max'),
|
||||
'email.required' => __('user.validation.email_required'),
|
||||
'email.email' => __('user.validation.email_invalid'),
|
||||
'email.unique' => __('user.validation.email_unique'),
|
||||
'email.max' => __('user.validation.email_max'),
|
||||
'password.confirmed' => __('user.validation.password_confirmed'),
|
||||
'password.min' => __('user.validation.password_min'),
|
||||
'current_password.required_with' => __('user.validation.current_password_required'),
|
||||
'current_password.current_password' => __('user.validation.current_password_invalid'),
|
||||
'language.in' => __('user.validation.language_invalid'),
|
||||
'country.size' => __('user.validation.country_size'),
|
||||
'country.alpha' => __('user.validation.country_alpha'),
|
||||
'timezone.in' => __('user.validation.timezone_invalid'),
|
||||
|
||||
// 연락처 정보
|
||||
'homepage.url' => __('user.validation.homepage_url'),
|
||||
'homepage.max' => __('user.validation.homepage_max'),
|
||||
'mobile.max' => __('user.validation.mobile_max'),
|
||||
'mobile.regex' => __('user.validation.mobile_regex'),
|
||||
'phone.max' => __('user.validation.phone_max'),
|
||||
'phone.regex' => __('user.validation.phone_regex'),
|
||||
|
||||
// 주소 정보
|
||||
'zipcode.max' => __('user.validation.zipcode_max'),
|
||||
'address.max' => __('user.validation.address_max'),
|
||||
'address_detail.max' => __('user.validation.address_detail_max'),
|
||||
|
||||
// 추가 정보
|
||||
'signature.max' => __('user.validation.signature_max'),
|
||||
'bio.max' => __('user.validation.bio_max'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
// 빈 password 필드 제거 (null로 변환하여 validation에서 무시되도록)
|
||||
if ($this->password === '') {
|
||||
$this->merge([
|
||||
'password' => null,
|
||||
'password_confirmation' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class UpdateUserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 전처리
|
||||
*
|
||||
* API 응답에서 로드된 roles(객체 배열)와 사용자가 선택한 role_ids가
|
||||
* 동시에 전송될 수 있으므로, role_ids가 있으면 roles를 제거합니다.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->has('role_ids') && $this->has('roles')) {
|
||||
$this->getInputSource()->remove('roles');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$userId = $this->route('user');
|
||||
$supportedLocales = implode(',', config('app.supported_locales', ['ko', 'en']));
|
||||
|
||||
$rules = [
|
||||
// 기본 정보
|
||||
'name' => 'required|string|max:255',
|
||||
'nickname' => 'nullable|string|max:50',
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
'max:255',
|
||||
Rule::unique(User::class, 'email')->ignore($userId),
|
||||
],
|
||||
'password' => ['nullable', 'confirmed', Password::min(8)],
|
||||
'language' => 'nullable|string|in:'.$supportedLocales,
|
||||
'country' => 'nullable|string|size:2|alpha',
|
||||
'timezone' => ['nullable', 'string', Rule::in(config('app.supported_timezones', ['Asia/Seoul']))],
|
||||
'status' => 'nullable|string|in:active,inactive,blocked,withdrawn',
|
||||
|
||||
// 연락처 정보
|
||||
'homepage' => 'nullable|url|max:255',
|
||||
'mobile' => ['nullable', 'string', 'max:20', 'regex:/^[0-9\-\+\(\)\s]+$/'],
|
||||
'phone' => ['nullable', 'string', 'max:20', 'regex:/^[0-9\-\+\(\)\s]+$/'],
|
||||
|
||||
// 주소 정보
|
||||
'zipcode' => 'nullable|string|max:10',
|
||||
'address' => 'nullable|string|max:255',
|
||||
'address_detail' => 'nullable|string|max:255',
|
||||
|
||||
// 추가 정보
|
||||
'signature' => 'nullable|string|max:1000',
|
||||
'bio' => 'nullable|string|max:5000',
|
||||
'admin_memo' => 'nullable|string|max:5000',
|
||||
|
||||
// 역할 정보 (객체 배열 또는 id 배열 모두 허용, 하나 이상 필수)
|
||||
'roles' => 'required_without:role_ids|array|min:1',
|
||||
'roles.*.id' => ['required', 'integer', Rule::exists(Role::class, 'id')],
|
||||
'role_ids' => 'required_without:roles|array|min:1',
|
||||
'role_ids.*' => ['integer', Rule::exists(Role::class, 'id')],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.user.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
// 기본 정보
|
||||
'name.required' => __('user.validation.name_required'),
|
||||
'name.string' => __('user.validation.name_string'),
|
||||
'name.max' => __('user.validation.name_max'),
|
||||
'nickname.string' => __('user.validation.nickname_string'),
|
||||
'nickname.max' => __('user.validation.nickname_max'),
|
||||
'email.required' => __('user.validation.email_required'),
|
||||
'email.email' => __('user.validation.email_invalid'),
|
||||
'email.unique' => __('user.validation.email_unique'),
|
||||
'email.max' => __('user.validation.email_max'),
|
||||
'password.confirmed' => __('user.validation.password_confirmed'),
|
||||
'password.min' => __('user.validation.password_min'),
|
||||
'language.in' => __('user.validation.language_invalid'),
|
||||
'country.size' => __('user.validation.country_size'),
|
||||
'country.alpha' => __('user.validation.country_alpha'),
|
||||
'timezone.in' => __('user.validation.timezone_invalid'),
|
||||
'status.in' => __('user.validation.status_invalid'),
|
||||
|
||||
// 연락처 정보
|
||||
'homepage.url' => __('user.validation.homepage_url'),
|
||||
'homepage.max' => __('user.validation.homepage_max'),
|
||||
'mobile.max' => __('user.validation.mobile_max'),
|
||||
'mobile.regex' => __('user.validation.mobile_regex'),
|
||||
'phone.max' => __('user.validation.phone_max'),
|
||||
'phone.regex' => __('user.validation.phone_regex'),
|
||||
|
||||
// 주소 정보
|
||||
'zipcode.max' => __('user.validation.zipcode_max'),
|
||||
'address.max' => __('user.validation.address_max'),
|
||||
'address_detail.max' => __('user.validation.address_detail_max'),
|
||||
|
||||
// 추가 정보
|
||||
'signature.max' => __('user.validation.signature_max'),
|
||||
'bio.max' => __('user.validation.bio_max'),
|
||||
'admin_memo.max' => __('user.validation.admin_memo_max'),
|
||||
|
||||
// 역할 정보
|
||||
'roles.required_without' => __('user.validation.roles_required'),
|
||||
'roles.min' => __('user.validation.roles_min'),
|
||||
'role_ids.required_without' => __('user.validation.roles_required'),
|
||||
'role_ids.min' => __('user.validation.roles_min'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 아바타 업로드 요청 클래스
|
||||
*
|
||||
* 프로필 이미지 업로드 시 사용되는 validation 규칙을 정의합니다.
|
||||
*/
|
||||
class UploadAvatarRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 최대 파일 크기 (KB)
|
||||
*/
|
||||
public const MAX_FILE_SIZE = 2048;
|
||||
|
||||
/**
|
||||
* 허용되는 MIME 타입 목록
|
||||
*/
|
||||
public const ALLOWED_MIMES = ['jpeg', 'png', 'gif', 'webp'];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'avatar' => [
|
||||
'required',
|
||||
'image',
|
||||
'mimes:'.implode(',', self::ALLOWED_MIMES),
|
||||
'max:'.self::MAX_FILE_SIZE,
|
||||
],
|
||||
];
|
||||
|
||||
return HookManager::applyFilters('core.user.upload_avatar_rules', $rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'avatar.required' => __('user.validation.avatar_required'),
|
||||
'avatar.image' => __('user.validation.avatar_image'),
|
||||
'avatar.mimes' => __('user.validation.avatar_mimes'),
|
||||
'avatar.max' => __('user.validation.avatar_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UserListRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 검색 가능한 필드 목록
|
||||
*/
|
||||
public const SEARCHABLE_FIELDS = ['name', 'email'];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// 'all'은 전체 필드 검색을 의미하는 특수 값
|
||||
$searchableFields = implode(',', array_merge(['all'], self::SEARCHABLE_FIELDS));
|
||||
|
||||
$rules = [
|
||||
'page' => 'integer|min:1',
|
||||
'per_page' => 'integer|min:1|max:100',
|
||||
|
||||
// 다중 검색 조건
|
||||
'filters' => 'nullable|array|max:10',
|
||||
'filters.*.field' => "required_with:filters|string|in:{$searchableFields}",
|
||||
'filters.*.value' => 'required_with:filters|string|max:255',
|
||||
'filters.*.operator' => 'nullable|string|in:like,eq,starts_with,ends_with',
|
||||
|
||||
'start_date' => 'nullable|date',
|
||||
'end_date' => 'nullable|date|after_or_equal:start_date',
|
||||
'date_filter' => 'nullable|string|in:all,week,month,custom',
|
||||
'sort_by' => 'nullable|string|in:created_at,name,email,last_login_at',
|
||||
'sort_order' => 'nullable|string|in:asc,desc',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.user.list_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'page.integer' => __('user.validation.page_integer'),
|
||||
'page.min' => __('user.validation.page_min'),
|
||||
'per_page.integer' => __('user.validation.per_page_integer'),
|
||||
'per_page.min' => __('user.validation.per_page_min'),
|
||||
'per_page.max' => __('user.validation.per_page_max'),
|
||||
'start_date.date' => __('user.validation.start_date_invalid'),
|
||||
'end_date.date' => __('user.validation.end_date_invalid'),
|
||||
'end_date.after_or_equal' => __('user.validation.end_date_after_start'),
|
||||
'date_filter.in' => __('user.validation.date_filter_invalid'),
|
||||
'sort_by.in' => __('user.validation.sort_by_invalid'),
|
||||
'sort_order.in' => __('user.validation.sort_order_invalid'),
|
||||
// 다중 검색 조건 관련 메시지
|
||||
'filters.array' => __('user.validation.filters_array'),
|
||||
'filters.max' => __('user.validation.filters_max'),
|
||||
'filters.*.field.required_with' => __('user.validation.filter_field_required'),
|
||||
'filters.*.field.in' => __('user.validation.filter_field_invalid'),
|
||||
'filters.*.value.required_with' => __('user.validation.filter_value_required'),
|
||||
'filters.*.value.max' => __('user.validation.filter_value_max'),
|
||||
'filters.*.operator.in' => __('user.validation.filter_operator_invalid'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
// value가 비어있는 filters 제거
|
||||
$filters = $this->filters;
|
||||
if (is_array($filters)) {
|
||||
$filters = array_filter($filters, function ($filter) {
|
||||
return ! empty($filter['value']);
|
||||
});
|
||||
// 인덱스 재정렬
|
||||
$filters = array_values($filters);
|
||||
$this->merge(['filters' => $filters ?: null]);
|
||||
}
|
||||
|
||||
// 기본값 설정
|
||||
$this->merge([
|
||||
'per_page' => $this->per_page ?? 15,
|
||||
'page' => $this->page ?? 1,
|
||||
'sort_by' => $this->sort_by ?? 'created_at',
|
||||
'sort_order' => $this->sort_order ?? 'desc',
|
||||
'date_filter' => $this->date_filter ?? 'all',
|
||||
]);
|
||||
|
||||
// 날짜 필터에 따른 기본 날짜 설정
|
||||
if ($this->date_filter === 'week' && ! $this->start_date && ! $this->end_date) {
|
||||
$this->merge([
|
||||
'start_date' => now()->subWeek()->format('Y-m-d'),
|
||||
'end_date' => now()->format('Y-m-d'),
|
||||
]);
|
||||
} elseif ($this->date_filter === 'month' && ! $this->start_date && ! $this->end_date) {
|
||||
$this->merge([
|
||||
'start_date' => now()->subMonth()->format('Y-m-d'),
|
||||
'end_date' => now()->format('Y-m-d'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user