storage url o'zgartirildi
This commit is contained in:
@@ -154,6 +154,12 @@ class Controller extends ExController
|
||||
{
|
||||
$category = Category::find($id);
|
||||
|
||||
if (empty($category)) {
|
||||
return [
|
||||
'status' => false,
|
||||
'characteristics' => []
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($category->characteristics) && count($category->characteristics) > 0) {
|
||||
$characteristics = $category->characteristics;
|
||||
|
||||
@@ -38,7 +38,7 @@ class Store extends FormRequest
|
||||
'brand_id' => 'required',
|
||||
'measurement_id' => 'nullable|exists:measurements,id',
|
||||
|
||||
'category_id' => 'required',
|
||||
'category_id' => 'required|integer|exists:categories,id',
|
||||
'colors' => 'array|required',
|
||||
'colors.*.color_id' => 'nullable',
|
||||
'colors.*.sizes' => 'nullable|array',
|
||||
|
||||
@@ -28,7 +28,7 @@ class Update extends FormRequest
|
||||
'price' => 'required|numeric',
|
||||
'price_discount' => 'nullable',
|
||||
'brand_id' => 'required',
|
||||
'category_id' => 'required',
|
||||
'category_id' => 'required|integer|exists:categories,id',
|
||||
'popular' => 'nullable',
|
||||
"calc" => [],
|
||||
'leader_of_sales' => 'nullable',
|
||||
|
||||
@@ -58,13 +58,6 @@ class Update
|
||||
|
||||
private function syncCategories()
|
||||
{
|
||||
$cats = $this->product->categories()->get();
|
||||
|
||||
$cats = array_map(function ($cat) {
|
||||
return $cat['id'];
|
||||
}, $cats->toArray());
|
||||
|
||||
$this->product->categories()->detach($cats);
|
||||
$this->product->categories()->attach([$this->request->getCategoryID()]);
|
||||
$this->product->categories()->sync([$this->request->getCategoryID()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1033,7 +1033,9 @@ export default {
|
||||
|
||||
watch: {
|
||||
"products.category_id": function (newVal) {
|
||||
this.getCharacteristics(newVal);
|
||||
if (newVal) {
|
||||
this.getCharacteristics(newVal);
|
||||
}
|
||||
},
|
||||
|
||||
"category.first": function (newVal) {
|
||||
@@ -1050,8 +1052,8 @@ export default {
|
||||
this.DetectCategoryTwo();
|
||||
} else {
|
||||
if (newVal.id) {
|
||||
this.product.category_id = newVal.id;
|
||||
this.getCharacteristics(newVal);
|
||||
this.products.category_id = newVal.id;
|
||||
this.getCharacteristics(newVal.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1178,7 +1180,7 @@ export default {
|
||||
this.category.two_view = true;
|
||||
} else {
|
||||
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) {
|
||||
id = id && id.id ? id.id : id;
|
||||
|
||||
if (!id) {
|
||||
this.characteristics = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const { data } = await axios.get(
|
||||
"/dashboard/products/characteristics/" + id
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user