'boolean', 'status' => ReleaseStatus::class, ]; } protected static function booted(): void { static::updating(function (ArticleRelease $release): void { $original = StatusValue::of($release->getOriginal('status')); if (! in_array($original, [ ReleaseStatus::Veroeffentlicht->value, ReleaseStatus::AbgeloestVerfuegbar->value, ], true)) { return; } $dirty = array_diff(array_keys($release->getDirty()), ['status', 'updated_at']); if ($dirty !== []) { throw new DomainRuleException('Ein veröffentlichter Artikel-Stand ist unveränderlich.'); } $next = StatusValue::of($release->status); if ($original === ReleaseStatus::Veroeffentlicht->value && $next !== ReleaseStatus::AbgeloestVerfuegbar->value) { throw new DomainRuleException('Ein veröffentlichter Artikel-Stand kann nur abgelöst werden.'); } }); } public function article(): BelongsTo { return $this->belongsTo(LicenseArticle::class, 'license_article_id'); } public function contents(): HasMany { return $this->hasMany(ReleaseContent::class)->orderBy('position'); } public function rootElementVersion(): BelongsTo { return $this->belongsTo(ContentElementVersion::class, 'root_element_version_id'); } public function rootCompositionVersion(): BelongsTo { return $this->belongsTo(CompositionVersion::class, 'root_composition_version_id'); } }