Files
sam-manage/app/Http/Requests/StoreMenuRequest.php
hskwon c94e1cff41 메뉴 관리 HTMX 에러 수정 및 개발도구 메뉴 동적 렌더링
- HTMX 응답 에러 수정: JSON 래핑 대신 HTML 직접 반환
  - MenuController, GlobalMenuController의 index 메소드 수정
  - index.blade.php, global-index.blade.php의 JSON 파싱 로직 제거

- 메뉴 options 필드 검증 추가
  - StoreMenuRequest, UpdateMenuRequest에 options 필드 추가
  - section 변경이 정상 저장되도록 수정

- 개발도구 메뉴 하드코딩 제거, DB 기반 동적 렌더링
  - sidebar.blade.php에서 하드코딩된 메뉴 제거
  - tools-menu.blade.php 컴포넌트 신규 생성
  - section=tools 메뉴가 하단 고정 영역에 동적 표시
2025-12-18 11:19:07 +09:00

73 lines
2.1 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreMenuRequest 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 [
'parent_id' => 'nullable|exists:menus,id',
'name' => 'required|string|max:100',
'url' => 'nullable|string|max:255',
'icon' => 'nullable|string|max:100',
'sort_order' => 'nullable|integer|min:0',
'is_active' => 'nullable|boolean',
'hidden' => 'nullable|boolean',
'is_external' => 'nullable|boolean',
'external_url' => 'nullable|string|max:255|required_if:is_external,1',
'options' => 'nullable|array',
'options.section' => 'nullable|string|in:main,tools,labs',
'options.meta' => 'nullable|array',
];
}
/**
* Get custom attributes for validator errors.
*
* @return array<string, string>
*/
public function attributes(): array
{
return [
'parent_id' => '부모 메뉴',
'name' => '메뉴명',
'url' => 'URL',
'icon' => '아이콘',
'sort_order' => '정렬 순서',
'is_active' => '활성 상태',
'hidden' => '숨김 여부',
'is_external' => '외부 링크',
'external_url' => '외부 URL',
];
}
/**
* Get custom messages for validator errors.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'parent_id.exists' => '존재하지 않는 부모 메뉴입니다.',
'external_url.required_if' => '외부 링크 사용 시 외부 URL은 필수입니다.',
];
}
}