*/ use ErbtZuordnung, HasFactory; /** * @return array */ protected function casts(): array { return [ 'land' => Land::class, 'kategorie' => DokumentKategorie::class, 'vertraulich' => 'boolean', 'groesse' => 'integer', ]; } protected function zuordnungsEltern(): ?Model { if ($this->dokumentable_type !== null) { return $this->dokumentable()->getResults(); } return $this->projekt()->first(); } /** @return BelongsTo */ public function projekt(): BelongsTo { return $this->belongsTo(Projekt::class); } /** @return MorphTo */ public function dokumentable(): MorphTo { return $this->morphTo(); } /** @return BelongsTo */ public function hochgeladenVon(): BelongsTo { return $this->belongsTo(User::class, 'hochgeladen_von'); } /** @return BelongsToMany */ public function freigaben(): BelongsToMany { return $this->belongsToMany(User::class, 'dokument_freigaben')->withTimestamps(); } }