- Mandant, Auftragnehmer, Projekt mit Suchreihenfolge, Abschnitt (PFA), Vertrag, Leistungsverzeichnis, Nachtrag (MKA nur als Bezug), Nachtragsposition, Dokument - Projektmitglieder mit Projektrolle, Freigaben für vertrauliche Dokumente - Mandant, Land und Projekt werden vom übergeordneten Datensatz übernommen; Fehlzuordnungen über Mandanten oder Projekte hinweg werden abgewiesen - Feste Morph-Map, Factories, Demodaten (Musterbahn, PFA 1–4, N14/N16/N21), Tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\DokumentKategorie;
|
|
use App\Models\Dokument;
|
|
use App\Models\Projekt;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<Dokument>
|
|
*/
|
|
class DokumentFactory extends Factory
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
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]);
|
|
}
|
|
}
|