diff --git a/src/database/factories/DocumentFactory.php b/src/database/factories/DocumentFactory.php index 017a6c2..064b979 100644 --- a/src/database/factories/DocumentFactory.php +++ b/src/database/factories/DocumentFactory.php @@ -16,7 +16,7 @@ class DocumentFactory extends Factory public function definition(): array { - $title = fake()->unique()->sentence(3); + $title = rtrim(fake()->unique()->words(3, true), '.'); return [ 'path' => $title . '.md', @@ -29,8 +29,9 @@ public function definition(): array } /** - * After creating, attach a translation in the document's default_locale. - * Pass an explicit ['title' => ..., 'content' => ...] via withTranslation() to override. + * After creating, attach a translation in the document's default_locale + * (skipped if a translation was already created via state, or if the + * caller used withoutTranslations()). */ public function configure(): static { @@ -45,7 +46,7 @@ public function configure(): static } /** - * Override the default_locale and create the corresponding translation. + * Override the default_locale (auto-translation will be created in this locale). */ public function defaultLocale(string $locale): static { @@ -53,10 +54,12 @@ public function defaultLocale(string $locale): static } /** - * Suppress automatic translation creation (caller will create manually). + * Suppress automatic translation creation. Uses Laravel's built-in + * withoutAfterCreating() to clear callbacks rather than appending a no-op + * (afterCreating appends, so a no-op closure does NOT override the configure() callback). */ public function withoutTranslations(): static { - return $this->afterCreating(fn () => null); + return $this->withoutAfterCreating(); } }