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,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ContentElementVersion extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'content_element_id',
|
||||
'number',
|
||||
'status',
|
||||
'content_hash',
|
||||
'body',
|
||||
'metadata',
|
||||
'change_note',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => ContentVersionStatus::class,
|
||||
'metadata' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::updating(function (ContentElementVersion $version): void {
|
||||
if (in_array(StatusValue::of($version->getOriginal('status')), [
|
||||
ContentVersionStatus::Bereit->value,
|
||||
ContentVersionStatus::Gesperrt->value,
|
||||
], true)) {
|
||||
throw new DomainRuleException('Eine bereitgestellte Inhaltsfassung ist unveränderlich.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function element(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ContentElement::class, 'content_element_id');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user