topic_id ?? 0); if ($topicId > 0) { return PermissionService::canEditPost($topicId); } return PermissionService::canCreatePost(); } public function failedAuthorizationMessage(): string { if (!is_user_logged_in()) { return 'You must be logged in to check a post slug.'; } return 'You do not have permission to check a post slug.'; } /** * `sanitize:title` is deliberately absent. The response reports the * sanitized form back to the author, so the sanitizing happens in * TopicService::previewSlug() where the verdict is formed — sanitizing * first would let input that reduces to '' fail `required` instead. */ public function rules() { return [ 'slug' => ['required', 'string', 'max:200'], 'topic_id' => ['nullable', 'integer', 'min:1'], ]; } public function messages() { return [ 'slug.required' => 'The post slug is required.', 'slug.string' => 'The post slug must be a string.', 'slug.max' => 'The post slug cannot exceed 200 characters.', 'topic_id.integer' => 'The post ID must be a valid integer.', 'topic_id.min' => 'The post ID must be at least 1.', ]; } }