Skip to content

Commit 6a60765

Browse files
shanerbaner82claude
andcommitted
Fix ArticleResource crash on create page by making record nullable
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b60c320 commit 6a60765

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

app/Filament/Resources/ArticleResource.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public static function form(Schema $schema): Schema
4040
->required()
4141
->maxLength(255)
4242
->live(onBlur: true)
43-
->afterStateUpdated(function (Article $article, Set $set, ?string $state): void {
44-
if ($article->isPublished()) {
43+
->afterStateUpdated(function (?Article $article, Set $set, ?string $state): void {
44+
if ($article?->isPublished()) {
4545
return;
4646
}
4747

@@ -53,11 +53,11 @@ public static function form(Schema $schema): Schema
5353
->maxLength(255)
5454
->live(onBlur: true)
5555
->unique(Article::class, 'slug', ignoreRecord: true)
56-
->disabled(fn (Article $article) => $article->isPublished())
56+
->disabled(fn (?Article $article) => $article?->isPublished() ?? false)
5757
->afterStateUpdated(
5858
fn (Set $set, ?string $state) => $set('slug', Str::slug($state))
5959
)
60-
->helperText(fn (Article $article) => $article->isPublished()
60+
->helperText(fn (?Article $article) => $article?->isPublished()
6161
? 'The slug cannot be changed after the article is published.'
6262
: false
6363
),

0 commit comments

Comments
 (0)