changes 0129092025 laptop
This commit is contained in:
@@ -227,8 +227,20 @@ public function update(Request $request, ImportTemplate $template)
|
||||
'client_id' => 'nullable|integer|exists:clients,id',
|
||||
'is_active' => 'boolean',
|
||||
'sample_headers' => 'nullable|array',
|
||||
'meta' => 'nullable|array',
|
||||
'meta.delimiter' => 'nullable|string|max:4',
|
||||
])->validate();
|
||||
|
||||
// Merge meta safely, preserving existing keys when not provided
|
||||
$newMeta = $template->meta ?? [];
|
||||
if (array_key_exists('meta', $data) && is_array($data['meta'])) {
|
||||
$newMeta = array_merge($newMeta, $data['meta']);
|
||||
// Drop empty delimiter to allow auto-detect
|
||||
if (array_key_exists('delimiter', $newMeta) && (!is_string($newMeta['delimiter']) || trim((string) $newMeta['delimiter']) === '')) {
|
||||
unset($newMeta['delimiter']);
|
||||
}
|
||||
}
|
||||
|
||||
$template->update([
|
||||
'name' => $data['name'],
|
||||
'description' => $data['description'] ?? null,
|
||||
@@ -237,6 +249,7 @@ public function update(Request $request, ImportTemplate $template)
|
||||
'client_id' => $data['client_id'] ?? null,
|
||||
'is_active' => $data['is_active'] ?? $template->is_active,
|
||||
'sample_headers' => $data['sample_headers'] ?? $template->sample_headers,
|
||||
'meta' => $newMeta,
|
||||
]);
|
||||
|
||||
return redirect()->route('importTemplates.edit', ['template' => $template->uuid])
|
||||
|
||||
Reference in New Issue
Block a user