'Laravel Nova 4 conditionally show field on preview

I am using Laravel 9 and Nova 4 and have a resource where a lot of the properties are nullable. I'd like the preview screen to only show a field if the value is not null. Looking at the nova docs methods like showOnIndex() and showOnDetail() etc accept a callback so that you can add a condition for whether to show them or not. Unfortunately the showOnPreview() doesn't accept a callback so is there another way that I can conditionally tell Nova to only show the field in the preview if the value isn't null?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source