value) && current_user_can('manage_options'); } public function failedAuthorizationMessage(): string { if (!is_user_logged_in()) { return 'You must be logged in to change the portal root mode.'; } return 'You do not have permission to change the portal root mode.'; } public function rules() { return [ 'enabled' => ['nullable'], ]; } /** * Read the switch from either a JSON body (real boolean) or a form post * ("true" / "1" / "on"), the way the settings screens elsewhere do. */ public function isEnabled(): bool { $value = $this->enabled; if ($value === null) { return false; } return filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ?? (bool) $value; } }