faker->sentence(3); return [ 'name' => $title, 'path' => 'documents/' . Str::slug($title) . '.pdf', 'exercice_id' => FinanceDocumentExercice::factory(), 'status' => $this->faker->randomElement(DocumentStatusEnum::cases()), 'published_at' => $this->faker->dateTimeBetween('-1 month', 'now'), 'unpublished_at' => null, ]; } /** * Ajoute automatiquement des tags à un document créé. */ public function withTags(int $count = 3): static { return $this->afterCreating(function (FinanceDocument $document) use ($count) { $tags = FinanceDocumentTag::factory()->count($count)->create(); $document->tags()->sync($tags->pluck('id')); }); } }