Datenmodell Kern: Projekt, PFA, Vertrag, LV, Nachtrag, Dokument
- 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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ca09d23a78
commit
6aac8b0a16
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Land;
|
||||
use App\Enums\NachtragStatus;
|
||||
use App\Models\Concerns\ErbtZuordnung;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Factories\NachtragFactory;
|
||||
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\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
/**
|
||||
* Nachtrag eines Auftragnehmers zu einem Vertrag. Geprüft wird je Nachtragsposition, ob die
|
||||
* Leistung schon im Vertrag enthalten ist. Die MKA ist nur eine Bezugsnummer (mka_bezug).
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $mandant_id
|
||||
* @property Land $land
|
||||
* @property int $projekt_id
|
||||
* @property int $vertrag_id
|
||||
* @property string $nummer
|
||||
* @property CarbonImmutable $eingang_am
|
||||
* @property string $betreff
|
||||
* @property list<string>|null $mka_bezug
|
||||
* @property NachtragStatus $status
|
||||
* @property int|null $zugewiesen_an
|
||||
* @property CarbonImmutable|null $created_at
|
||||
* @property CarbonImmutable|null $updated_at
|
||||
*/
|
||||
#[Table('nachtraege')]
|
||||
#[Fillable(['vertrag_id', 'nummer', 'eingang_am', 'betreff', 'mka_bezug', 'status', 'zugewiesen_an'])]
|
||||
class Nachtrag extends Model
|
||||
{
|
||||
/** @use HasFactory<NachtragFactory> */
|
||||
use ErbtZuordnung, HasFactory;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'land' => Land::class,
|
||||
'eingang_am' => 'date',
|
||||
'mka_bezug' => 'array',
|
||||
'status' => NachtragStatus::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 BelongsTo<User, $this> */
|
||||
public function zugewiesenAn(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'zugewiesen_an');
|
||||
}
|
||||
|
||||
/** @return HasMany<Nachtragsposition, $this> */
|
||||
public function positionen(): HasMany
|
||||
{
|
||||
return $this->hasMany(Nachtragsposition::class)->orderBy('sortierung')->orderBy('id');
|
||||
}
|
||||
|
||||
/** @return MorphMany<Dokument, $this> */
|
||||
public function dokumente(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Dokument::class, 'dokumentable');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user