- 역할 목록: 테넌트/Guard 컬럼 추가, Guard 필터 드롭다운 추가 - 역할 등록/수정: Guard 선택 기능 추가 (API/Web) - 권한 선택 UI를 메뉴 기반 매트릭스로 변경 (7가지 권한 유형) - 테넌트 미선택 시 역할 등록 차단 - pagination.js 디버그 로그 제거
71 lines
2.1 KiB
PHP
71 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StoreRoleRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true; // 권한 체크는 middleware에서 처리
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$tenantId = session('selected_tenant_id');
|
|
$guardName = $this->input('guard_name', 'api');
|
|
|
|
return [
|
|
'name' => [
|
|
'required',
|
|
'string',
|
|
'max:100',
|
|
Rule::unique('roles', 'name')
|
|
->where('tenant_id', $tenantId)
|
|
->where('guard_name', $guardName),
|
|
],
|
|
'guard_name' => 'required|in:api,web',
|
|
'description' => 'nullable|string|max:500',
|
|
'menu_permissions' => 'nullable|array',
|
|
'menu_permissions.*' => 'nullable|array',
|
|
'menu_permissions.*.*' => 'in:view,create,update,delete,approve,export,manage',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'name' => '역할 이름',
|
|
'guard_name' => 'Guard',
|
|
'description' => '설명',
|
|
'menu_permissions' => '메뉴 권한',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the error messages for the defined validation rules.
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'name.required' => '역할 이름은 필수입니다.',
|
|
'name.unique' => '이미 존재하는 역할 이름입니다.',
|
|
'name.max' => '역할 이름은 최대 100자까지 입력 가능합니다.',
|
|
'guard_name.required' => 'Guard는 필수입니다.',
|
|
'guard_name.in' => 'Guard는 api 또는 web만 선택 가능합니다.',
|
|
'description.max' => '설명은 최대 500자까지 입력 가능합니다.',
|
|
];
|
|
}
|
|
}
|