fix(products): keep category when update sends null product_categories_id

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-21 16:59:15 +07:00
co-authored by Claude Sonnet 5.5
parent a443ec3bf6
commit 4f3442190e
2 changed files with 39 additions and 0 deletions
@@ -173,6 +173,10 @@ class ProductController extends Controller
'features' => 'nullable|array',
]);
if (array_key_exists('product_categories_id', $validated) && $validated['product_categories_id'] === null) {
unset($validated['product_categories_id']);
}
if (isset($validated['name']) && $validated['name'] !== $product->name) {
$validated['slug'] = Str::slug($validated['name']);
}