Quellübung mit stabiler Kennung und Inhaltswert, genau ein Stand je Prüfsumme, bewusste Übernahme als neue lokale Fassung, lokale Ergänzungen bleiben erhalten, Ausblenden an der Quelle setzt nur die Verfügbarkeit. Seite Übernahme (Shinkan), Feldzuordnung, ADR-49 (inklusive Abweichung bei der Mediensperre), Abnahmestand und Rückfallverfahren. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
82 lines
2.2 KiB
PHP
82 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class CompositionVersion extends Model
|
|
{
|
|
protected $fillable = [
|
|
'composition_id',
|
|
'number',
|
|
'status',
|
|
'members_hash',
|
|
'resolved_hash',
|
|
'learning_goal',
|
|
'duration_minutes',
|
|
'material_note',
|
|
'duration_max',
|
|
'prerequisites',
|
|
'structure_hash',
|
|
'source_snapshot_id',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status' => ContentVersionStatus::class,
|
|
];
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::updating(function (CompositionVersion $version): void {
|
|
$original = StatusValue::of($version->getOriginal('status'));
|
|
|
|
if (! in_array($original, [
|
|
ContentVersionStatus::Bereit->value,
|
|
ContentVersionStatus::Gesperrt->value,
|
|
], true)) {
|
|
return;
|
|
}
|
|
|
|
$dirty = array_diff(array_keys($version->getDirty()), ['status', 'updated_at']);
|
|
|
|
if ($dirty !== [] || $original === ContentVersionStatus::Gesperrt->value) {
|
|
throw new DomainRuleException('Eine bestätigte Kompositionsfassung ist unveränderlich.');
|
|
}
|
|
|
|
if (StatusValue::of($version->status) !== ContentVersionStatus::Gesperrt->value) {
|
|
throw new DomainRuleException('Eine bestätigte Kompositionsfassung kann nur gesperrt werden.');
|
|
}
|
|
});
|
|
}
|
|
|
|
public function composition(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Composition::class);
|
|
}
|
|
|
|
public function members(): HasMany
|
|
{
|
|
return $this->hasMany(CompositionMember::class)->orderBy('position');
|
|
}
|
|
|
|
public function variants(): HasMany
|
|
{
|
|
return $this->hasMany(CompositionVersionVariant::class)->orderBy('position');
|
|
}
|
|
|
|
public function attestations(): HasMany
|
|
{
|
|
return $this->hasMany(CompatibilityAttestation::class);
|
|
}
|
|
|
|
public function displayEvents(): HasMany
|
|
{
|
|
return $this->hasMany(CompositionVersionDisplayEvent::class)->orderBy('occurred_at');
|
|
}
|
|
}
|