|string> */ public function rules(): array { return [ 'name' => [ 'required', 'string', 'max:255', function ($attribute, $value, $fail) { $guardName = $this->input('guard_name', 'web'); $tenantId = $this->input('tenant_id'); $service = app(PermissionService::class); if ($service->isNameExists($value, $guardName, null, $tenantId)) { $fail('이 권한 이름은 이미 사용 중입니다.'); } }, ], 'guard_name' => 'required|string|max:255', 'tenant_id' => 'nullable|exists:tenants,id', ]; } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'name' => '권한 이름', 'guard_name' => '가드 이름', 'tenant_id' => '테넌트', ]; } /** * Get custom messages for validator errors. * * @return array */ public function messages(): array { return [ 'name.required' => '권한 이름을 입력해주세요.', 'name.max' => '권한 이름은 255자를 초과할 수 없습니다.', 'guard_name.required' => '가드 이름을 입력해주세요.', 'tenant_id.exists' => '존재하지 않는 테넌트입니다.', ]; } }