- 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>
73 lines
2.0 KiB
PHP
73 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\Land;
|
|
use App\Enums\VerarbeitungStatus;
|
|
use App\Models\Concerns\ErbtZuordnung;
|
|
use Carbon\CarbonImmutable;
|
|
use Database\Factories\LeistungsverzeichnisFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\Table;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
|
|
/**
|
|
* Ein LV des Vertrags. Die Dateien (X86, D86, PDF) hängen als Dokumente daran,
|
|
* Positionen und Vorbemerkungen kommen mit dem GAEB-Import dazu.
|
|
*
|
|
* @property int $id
|
|
* @property int $mandant_id
|
|
* @property Land $land
|
|
* @property int $projekt_id
|
|
* @property int $vertrag_id
|
|
* @property string $bezeichnung
|
|
* @property VerarbeitungStatus $import_status
|
|
* @property string|null $import_fehler
|
|
* @property CarbonImmutable|null $created_at
|
|
* @property CarbonImmutable|null $updated_at
|
|
*/
|
|
#[Table('leistungsverzeichnisse')]
|
|
#[Fillable(['vertrag_id', 'bezeichnung', 'import_status', 'import_fehler'])]
|
|
class Leistungsverzeichnis extends Model
|
|
{
|
|
/** @use HasFactory<LeistungsverzeichnisFactory> */
|
|
use ErbtZuordnung, HasFactory;
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'land' => Land::class,
|
|
'import_status' => VerarbeitungStatus::class,
|
|
];
|
|
}
|
|
|
|
protected function zuordnungsEltern(): ?Model
|
|
{
|
|
return $this->vertrag()->first();
|
|
}
|
|
|
|
/** @return BelongsTo<Projekt, $this> */
|
|
public function projekt(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Projekt::class);
|
|
}
|
|
|
|
/** @return BelongsTo<Vertrag, $this> */
|
|
public function vertrag(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Vertrag::class);
|
|
}
|
|
|
|
/** @return MorphMany<Dokument, $this> */
|
|
public function dokumente(): MorphMany
|
|
{
|
|
return $this->morphMany(Dokument::class, 'dokumentable');
|
|
}
|
|
}
|