Ergaenze Stammdaten, Suche, Dimensionen, Abdeckung und Ausgabenachweis
Deploy Test / test (push) Successful in 17s
Deploy Test / deploy (push) Successful in 25s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-16 08:24:23 +01:00
1 parent 7b54c38623
commit 5e763d15ec
23 files changed
+661 -5

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
<?php
namespace App\Domain\Catalog;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
class IdentityProfile
{
/**
* @param array<string, mixed> $fields
*/
public function fill(Model $subject, array $fields, ?User $actor = null): void
{
foreach ($fields as $field => $value) {
$next = is_string($value) ? trim($value) : $value;
$next = $next === '' ? null : $next;
$before = $subject->getAttribute($field);
$before = $before === '' ? null : $before;
if ($before === $next) {
continue;
}
$subject->setAttribute($field, $next);
IdentityChange::query()->create([
'subject_type' => $subject->getMorphClass(),
'subject_id' => $subject->getKey(),
'field' => $field,
'before' => $before,
'after' => $next,
'actor_id' => $actor?->id,
'occurred_at' => now(),
]);
}
$subject->save();
}
}