TextInput with visibleOn() and visible()

I want to show published date on edit page only and only if the published date is not null, I am doing like following but I am getting error on create page.

App\Filament\Resources\{closure}(): Argument #1 ($record) must be of type App\Models\ModelName, null given


TextInput::make('published_at')
    ->disabled()
    ->formatStateUsing(fn($record) => $record?->published_at?->format('M d, Y - h:i:s A'))
    ->visibleOn('edit')
    ->visible(fn(ModelName $record): bool => (bool)$record->published_at),
Was this page helpful?