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>
37 lines
1.4 KiB
PHP
37 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* Durchführungsvariante einer Übungsfassung. Der Schlüssel ist je Fassung eindeutig und bleibt über Fassungen hinweg
|
|
* gleich, damit eine Auswahl im Modul oder Programm und der Abgleich mit einer Quelle dieselbe Variante meinen.
|
|
* Wie die Mitglieder ist sie nur im Entwurf der Fassung schreibbar.
|
|
*/
|
|
class CompositionVersionVariant extends Model
|
|
{
|
|
protected $fillable = ['composition_version_id', 'key', 'position', 'name', 'description'];
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (CompositionVersionVariant $variant): void {
|
|
$status = CompositionVersion::query()->whereKey($variant->composition_version_id)->value('status');
|
|
|
|
if (StatusValue::of($status) === ContentVersionStatus::Bereit->value) {
|
|
throw new DomainRuleException('Eine bestätigte Kompositionsfassung nimmt keine weiteren Varianten auf.');
|
|
}
|
|
});
|
|
|
|
static::updating(function (): void {
|
|
throw new DomainRuleException('Varianten einer Komposition werden nicht verändert, sondern durch eine neue Fassung ersetzt.');
|
|
});
|
|
}
|
|
|
|
public function compositionVersion(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CompositionVersion::class);
|
|
}
|
|
}
|