You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 Refactor Cleanup started 🆙
This commit is contained in:
+9
-11
@@ -451,20 +451,18 @@ class CatalogItemsRelationManager extends RelationManager
|
||||
])
|
||||
->action(function (array $data, CatalogItem $record): void {
|
||||
// Transform any null or empty values to empty strings
|
||||
$data = collect($data)->map(function ($value) {
|
||||
if ($value === null || $value === '') {
|
||||
return '';
|
||||
}
|
||||
if (is_bool($value)) {
|
||||
return $value ? '1' : '0';
|
||||
}
|
||||
|
||||
return $value;
|
||||
})->toArray();
|
||||
$normalized = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$normalized[(string) $key] = match (true) {
|
||||
$value === null, $value === '' => '',
|
||||
is_bool($value) => $value ? '1' : '0',
|
||||
default => $value,
|
||||
};
|
||||
}
|
||||
|
||||
$itemBase = $record->itemBase;
|
||||
if ($itemBase) {
|
||||
$itemBase->forceFill($data)->save();
|
||||
$itemBase->forceFill($normalized)->save();
|
||||
}
|
||||
})
|
||||
->visible(function (CatalogItem $record): bool {
|
||||
|
||||
Reference in New Issue
Block a user