storage url o'zgartirildi

This commit is contained in:
2026-04-28 17:53:06 +05:00
parent 290dd2dddb
commit b8a4efadc2
5 changed files with 22 additions and 14 deletions

View File

@@ -154,6 +154,12 @@ class Controller extends ExController
{ {
$category = Category::find($id); $category = Category::find($id);
if (empty($category)) {
return [
'status' => false,
'characteristics' => []
];
}
if (!empty($category->characteristics) && count($category->characteristics) > 0) { if (!empty($category->characteristics) && count($category->characteristics) > 0) {
$characteristics = $category->characteristics; $characteristics = $category->characteristics;

View File

@@ -38,7 +38,7 @@ class Store extends FormRequest
'brand_id' => 'required', 'brand_id' => 'required',
'measurement_id' => 'nullable|exists:measurements,id', 'measurement_id' => 'nullable|exists:measurements,id',
'category_id' => 'required', 'category_id' => 'required|integer|exists:categories,id',
'colors' => 'array|required', 'colors' => 'array|required',
'colors.*.color_id' => 'nullable', 'colors.*.color_id' => 'nullable',
'colors.*.sizes' => 'nullable|array', 'colors.*.sizes' => 'nullable|array',

View File

@@ -28,7 +28,7 @@ class Update extends FormRequest
'price' => 'required|numeric', 'price' => 'required|numeric',
'price_discount' => 'nullable', 'price_discount' => 'nullable',
'brand_id' => 'required', 'brand_id' => 'required',
'category_id' => 'required', 'category_id' => 'required|integer|exists:categories,id',
'popular' => 'nullable', 'popular' => 'nullable',
"calc" => [], "calc" => [],
'leader_of_sales' => 'nullable', 'leader_of_sales' => 'nullable',

View File

@@ -58,13 +58,6 @@ class Update
private function syncCategories() private function syncCategories()
{ {
$cats = $this->product->categories()->get(); $this->product->categories()->sync([$this->request->getCategoryID()]);
$cats = array_map(function ($cat) {
return $cat['id'];
}, $cats->toArray());
$this->product->categories()->detach($cats);
$this->product->categories()->attach([$this->request->getCategoryID()]);
} }
} }

View File

@@ -1033,7 +1033,9 @@ export default {
watch: { watch: {
"products.category_id": function (newVal) { "products.category_id": function (newVal) {
if (newVal) {
this.getCharacteristics(newVal); this.getCharacteristics(newVal);
}
}, },
"category.first": function (newVal) { "category.first": function (newVal) {
@@ -1050,8 +1052,8 @@ export default {
this.DetectCategoryTwo(); this.DetectCategoryTwo();
} else { } else {
if (newVal.id) { if (newVal.id) {
this.product.category_id = newVal.id; this.products.category_id = newVal.id;
this.getCharacteristics(newVal); this.getCharacteristics(newVal.id);
} }
} }
} }
@@ -1178,7 +1180,7 @@ export default {
this.category.two_view = true; this.category.two_view = true;
} else { } else {
this.getCharacteristics(this.category.first.id); this.getCharacteristics(this.category.first.id);
this.product.category_id = this.category.first.id; this.products.category_id = this.category.first.id;
} }
}, },
@@ -1197,6 +1199,13 @@ export default {
}, },
async getCharacteristics(id) { async getCharacteristics(id) {
id = id && id.id ? id.id : id;
if (!id) {
this.characteristics = [];
return;
}
const { data } = await axios.get( const { data } = await axios.get(
"/dashboard/products/characteristics/" + id "/dashboard/products/characteristics/" + id
); );