From b9856f4bf8711b0d7d89d67d9eb1b2f9bf169cf0 Mon Sep 17 00:00:00 2001 From: husanjon Date: Tue, 28 Apr 2026 18:06:13 +0500 Subject: [PATCH] storage url o'zgartirildi --- .../Dashboard/Product/Controller.php | 7 +++ resources/js/components/ProductEdit.vue | 20 ++++++-- resources/js/components/ProductStore.vue | 50 +++++++++++++++---- 3 files changed, 63 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/Dashboard/Product/Controller.php b/app/Http/Controllers/Dashboard/Product/Controller.php index 3c539c2..5104a8d 100755 --- a/app/Http/Controllers/Dashboard/Product/Controller.php +++ b/app/Http/Controllers/Dashboard/Product/Controller.php @@ -152,6 +152,13 @@ class Controller extends ExController */ public function characteristics($id) { + if (!ctype_digit((string) $id)) { + return [ + 'status' => false, + 'characteristics' => [] + ]; + } + $category = Category::find($id); if (empty($category)) { diff --git a/resources/js/components/ProductEdit.vue b/resources/js/components/ProductEdit.vue index b72d613..75d0d06 100755 --- a/resources/js/components/ProductEdit.vue +++ b/resources/js/components/ProductEdit.vue @@ -1048,13 +1048,15 @@ export default { "category.two": function (newVal) { if (this.watch_count.two > 1) { - if (newVal.parents.length > 0) { + if (!newVal || !newVal.id) { + return; + } + + if (newVal.parents && newVal.parents.length > 0) { this.DetectCategoryTwo(); } else { - if (newVal.id) { - this.products.category_id = newVal.id; - this.getCharacteristics(newVal.id); - } + this.products.category_id = newVal.id; + this.getCharacteristics(newVal.id); } } @@ -1063,6 +1065,10 @@ export default { "category.three": function (newVal) { if (this.watch_count.three > 1) { + if (!newVal || !newVal.id) { + return; + } + this.DetectCategoryThree(); } @@ -1206,6 +1212,10 @@ export default { }, DetectCategoryThree() { + if (!this.category.three || !this.category.three.id) { + return; + } + this.getCharacteristics(this.category.three.id); this.products.category_id = this.category.three.id; }, diff --git a/resources/js/components/ProductStore.vue b/resources/js/components/ProductStore.vue index a0dc39c..deed6db 100755 --- a/resources/js/components/ProductStore.vue +++ b/resources/js/components/ProductStore.vue @@ -1153,7 +1153,9 @@ export default { watch: { "product.category_id": function (newVal) { - this.getCharacteristics(newVal); + if (newVal) { + this.getCharacteristics(newVal); + } }, "category.first": function (newVal) { @@ -1161,16 +1163,22 @@ export default { }, "category.two": function (newVal) { - if (newVal.parents.length > 0) { + if (!newVal || !newVal.id) { + return; + } + + if (newVal.parents && newVal.parents.length > 0) { this.DetectCategoryTwo(); } else { - if (newVal.id) { - this.product.category_id = newVal.id; - } + this.product.category_id = newVal.id; } }, "category.three": function (newVal) { + if (!newVal || !newVal.id) { + return; + } + this.DetectCategoryThree(); }, }, @@ -1367,6 +1375,13 @@ export default { }, async getCharacteristics(id) { + id = id && id.id ? id.id : id; + + if (!id) { + this.characteristics = []; + return; + } + const { data } = await axios.get( "/dashboard/products/characteristics/" + id ); @@ -1382,10 +1397,16 @@ export default { this.category.three = {}; this.category.three_view = false; - if (this.category.first.parents.length > 0) { + if (!this.category.first || !this.category.first.id) { + this.product.category_id = null; + return; + } + + this.product.category_id = this.category.first.id; + this.getCharacteristics(this.category.first.id); + + if (this.category.first.parents && this.category.first.parents.length > 0) { this.category.two_view = true; - } else { - this.product.category_id = this.category.first.id; } }, @@ -1393,12 +1414,23 @@ export default { this.category.three = {}; this.category.three_view = false; - if (this.category.two.parents.length > 0) { + if (!this.category.two || !this.category.two.id) { + return; + } + + this.product.category_id = this.category.two.id; + this.getCharacteristics(this.category.two.id); + + if (this.category.two.parents && this.category.two.parents.length > 0) { this.category.three_view = true; } }, DetectCategoryThree() { + if (!this.category.three || !this.category.three.id) { + return; + } + this.product.category_id = this.category.three.id; },