- popups 테이블 마이그레이션 생성 - Popup 모델 (BelongsToTenant, SoftDeletes) - PopupService CRUD 구현 - FormRequest 검증 (Store/Update) - PopupController 6개 엔드포인트 - Swagger 문서 (PopupApi.php) - PROJECT_DEVELOPMENT_POLICY.md 정책 준수
54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\V1\Popup;
|
|
|
|
use App\Models\Popups\Popup;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdatePopupRequest 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 [
|
|
'target_type' => ['sometimes', 'string', Rule::in(array_keys(Popup::TARGET_TYPES))],
|
|
'target_id' => ['nullable', 'integer', 'exists:departments,id'],
|
|
'title' => ['sometimes', 'string', 'max:200'],
|
|
'content' => ['sometimes', 'string'],
|
|
'status' => ['sometimes', 'string', Rule::in(array_keys(Popup::STATUSES))],
|
|
'started_at' => ['nullable', 'date'],
|
|
'ended_at' => ['nullable', 'date', 'after_or_equal:started_at'],
|
|
'options' => ['nullable', 'array'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom messages for validator errors.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'target_type.in' => __('validation.in', ['attribute' => '대상 유형']),
|
|
'target_id.exists' => __('validation.exists', ['attribute' => '대상 부서']),
|
|
'title.max' => __('validation.max.string', ['attribute' => '제목', 'max' => 200]),
|
|
'status.in' => __('validation.in', ['attribute' => '상태']),
|
|
'ended_at.after_or_equal' => __('validation.after_or_equal', ['attribute' => '종료일', 'date' => '시작일']),
|
|
];
|
|
}
|
|
}
|