Ergänze das U1-Fachmodell für Inhalt, Paket und Angebot.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2035c46edd
commit
2ded4b7fad
35 files changed
+2115
No files matched your search
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ReleaseContent extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'article_release_id',
|
||||
'position',
|
||||
'content_element_version_id',
|
||||
'role',
|
||||
'path',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (ReleaseContent $content): void {
|
||||
$status = StatusValue::of(ArticleRelease::query()->whereKey($content->article_release_id)->value('status'));
|
||||
|
||||
if ($status !== ReleaseStatus::Entwurf->value) {
|
||||
throw new DomainRuleException('Der Inhalt eines Artikel-Stands wird nur im Entwurf festgeschrieben.');
|
||||
}
|
||||
});
|
||||
|
||||
static::updating(function (): void {
|
||||
throw new DomainRuleException('Der festgeschriebene Inhalt eines Artikel-Stands ist unveränderlich.');
|
||||
});
|
||||
}
|
||||
|
||||
public function release(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ArticleRelease::class, 'article_release_id');
|
||||
}
|
||||
|
||||
public function elementVersion(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ContentElementVersion::class, 'content_element_version_id');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user