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>
66 lines
1.8 KiB
PHP
66 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class CompositionMember extends Model
|
|
{
|
|
protected $fillable = [
|
|
'composition_version_id',
|
|
'position',
|
|
'role',
|
|
'placement_note',
|
|
'content_element_version_id',
|
|
'nested_composition_version_id',
|
|
'variant_id',
|
|
'requirement',
|
|
'variant_selection',
|
|
];
|
|
|
|
public const REQUIRED = 'erforderlich';
|
|
|
|
public const SUPPLEMENTARY = 'ergaenzend';
|
|
|
|
protected function casts(): array
|
|
{
|
|
return ['variant_selection' => 'array'];
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (CompositionMember $member): void {
|
|
$status = CompositionVersion::query()->whereKey($member->composition_version_id)->value('status');
|
|
|
|
if (StatusValue::of($status) === ContentVersionStatus::Bereit->value) {
|
|
throw new DomainRuleException('Eine bestätigte Kompositionsfassung nimmt keine weiteren Mitglieder auf.');
|
|
}
|
|
});
|
|
|
|
static::updating(function (): void {
|
|
throw new DomainRuleException('Mitglieder einer Komposition werden nicht verändert, sondern durch eine neue Fassung ersetzt.');
|
|
});
|
|
}
|
|
|
|
public function compositionVersion(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CompositionVersion::class);
|
|
}
|
|
|
|
public function contentElementVersion(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ContentElementVersion::class);
|
|
}
|
|
|
|
public function variant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CompositionVersionVariant::class, 'variant_id');
|
|
}
|
|
|
|
public function nestedCompositionVersion(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CompositionVersion::class, 'nested_composition_version_id');
|
|
}
|
|
}
|