*/ class DokumentFactory extends Factory { /** * @return array */ public function definition(): array { $uuid = (string) Str::uuid(); return [ 'projekt_id' => Projekt::factory(), 'kategorie' => DokumentKategorie::Sonstiges, 'dateiname' => 'beispiel.pdf', 'pfad' => 'dokumente/'.$uuid.'.pdf', 'mime_type' => 'application/pdf', 'groesse' => fake()->numberBetween(10_000, 5_000_000), 'sha256' => hash('sha256', $uuid), 'vertraulich' => false, ]; } /** * Dokument zu einem LV, Nachtrag oder Vertrag; Projekt, Mandant und Land kommen von dort. */ public function zu(Model $dokumentable, DokumentKategorie $kategorie): static { return $this->state(fn (array $attributes) => [ 'projekt_id' => null, 'dokumentable_type' => $dokumentable->getMorphClass(), 'dokumentable_id' => $dokumentable->getKey(), 'kategorie' => $kategorie, ]); } public function vertraulich(): static { return $this->state(fn (array $attributes) => ['vertraulich' => true]); } }