readable`, so private and hidden * topics never leak regardless of this gate. */ public function authorize() { return PortalAccess::canView(); } public function failedAuthorizationMessage(): string { return PortalAccess::deniedMessage(); } public function rules() { // `sortBy` is newest, oldest or votes, and anything else reads as // newest — see TopicController::all(). Lenient on purpose: it arrives // from the listing's `?sort=`, and a stale link should not fail the list. $rules = [ 'search' => ['nullable', 'string', 'sanitize:text', 'max:200'], 'name' => ['nullable', 'string', 'sanitize:text', 'max:200'], 'sortBy' => ['nullable', 'string', 'sanitize:key', 'max:50'], 'page' => ['nullable', 'integer', 'min:1'], 'per_page' => ['nullable', 'integer', 'min:1', 'max:100'], 'stages' => ['nullable', 'string', 'sanitize:text', 'max:200'], 'topic-types' => ['nullable', 'string', 'sanitize:text', 'max:200'], 'statuses' => ['nullable', 'string', 'sanitize:text', 'max:200'], 'tags' => ['nullable', 'string', 'sanitize:text', 'max:200'], 'visibility' => ['nullable', 'string', 'sanitize:text', 'max:20'], 'my_topics' => ['nullable', 'string', 'sanitize:text', 'max:5'], 'followed' => ['nullable', 'string', 'sanitize:text', 'max:5'], 'view' => ['nullable', 'string', 'sanitize:key', 'max:40'], // see ExtensionPoints::topicListQuery() ]; // Term slugs of a taxonomy another plugin files topics under. foreach (array_keys(TopicTaxonomies::all()) as $param) { $rules[$param] = ['nullable', 'string', 'sanitize:text', 'max:200']; } return $rules; } public function messages() { return [ 'search.max' => 'The search parameter cannot exceed 200 characters.', 'sortBy.in' => 'The sort by parameter must be either newest or oldest.', 'page.min' => 'The page parameter must be at least 1.', 'per_page.min' => 'The per_page parameter must be at least 1.', 'per_page.max' => 'The per_page parameter cannot exceed 100.', 'stages.max' => 'The stages parameter cannot exceed 200 characters.', 'topic-types.max' => 'The topic-types parameter cannot exceed 200 characters.', 'statuses.max' => 'The statuses parameter cannot exceed 200 characters.', 'tags.max' => 'The tags parameter cannot exceed 200 characters.', ]; } }