CI Feature / test (push) Successful in 3m32s
Neuer kind 'exercise', Varianten je Fassung, Verwendung (erforderlich/ergänzend) und Variantenauswahl am einbindenden Mitglied; der Stand schreibt nur gewählte Varianten fest. Änderungsnachweis über structure_hash. Formatierte Anleitung im Mitgliederbereich und PDF (Fußzeile, Metadaten, Ausgabenachweis, keine gespeicherten Kopien); Sperre trifft nur das Medium. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
81 lines
2.2 KiB
PHP
81 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',
|
|
];
|
|
|
|
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');
|
|
}
|
|
}
|