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,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class BundleItem extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'bundle_version_id',
|
||||
'position',
|
||||
'license_article_id',
|
||||
'nested_bundle_id',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (BundleItem $item): void {
|
||||
$status = BundleVersion::query()->whereKey($item->bundle_version_id)->value('status');
|
||||
|
||||
if (StatusValue::of($status) === BundleStatus::Veroeffentlicht->value) {
|
||||
throw new DomainRuleException('Eine veröffentlichte Paketfassung nimmt keine weiteren Bestandteile auf.');
|
||||
}
|
||||
});
|
||||
|
||||
static::updating(function (): void {
|
||||
throw new DomainRuleException('Bestandteile einer Paketfassung sind unveränderlich.');
|
||||
});
|
||||
}
|
||||
|
||||
public function bundleVersion(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BundleVersion::class);
|
||||
}
|
||||
|
||||
public function article(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(LicenseArticle::class, 'license_article_id');
|
||||
}
|
||||
|
||||
public function nestedBundle(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Bundle::class, 'nested_bundle_id');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user