Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciframa committed Nov 2, 2024
1 parent 8884cee commit f16d1cf
Show file tree
Hide file tree
Showing 6 changed files with 520 additions and 125 deletions.
5 changes: 5 additions & 0 deletions Fitmo_backend/app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,17 @@ public function getMaxId()

public function updateCategories(Request $categories)
{
$alphabet = range('A', 'Z');
foreach ($categories[0] as $category) {
$categoryFromDb = Category::find($category["id"]);
if (!$categoryFromDb) {
$parentCategory = Category::find($category["id_parent"]);
$categoryFromDb = new Category();
$categoryFromDb["id"] = $category["id"];
$categoryFromDb["id_parent"] = $category["id_parent"];
$categoryFromDb["name"] = $category["name"];
$categoryFromDb["childIndex"] = $category["index"];
$categoryFromDb["path"] = isset($parentCategory["path"]) ? $parentCategory["path"] . $alphabet[$category["index"]] : $alphabet[$category["index"]];
if (isset($category["image"]) && $category["image"]) {
$path = 'categories/';
if ($categoryFromDb["image_path"]) {
Expand All @@ -168,9 +171,11 @@ public function updateCategories(Request $categories)
$img->writeImage($path . "/" . $category['image']["image_path"]);
}
} else {
$parentCategory = Category::find($category["id_parent"]);
$categoryFromDb["id_parent"] = $category["id_parent"];
$categoryFromDb["name"] = $category["name"];
$categoryFromDb["childIndex"] = $category["index"];
$categoryFromDb["path"] = isset($parentCategory["path"]) ? $parentCategory["path"] . $alphabet[$category["index"]] : $alphabet[$category["index"]];

if (isset($category["image"]) && $category["image"]) {
$path = 'categories/';
Expand Down
3 changes: 1 addition & 2 deletions Fitmo_backend/app/Http/Controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ public function getProductById($id)
public function getCategoryProducts($categoryName, Request $request)
{
$categoryName = join("/", explode(",", $categoryName));
$products = [];
$categories = Category::where(
'path',
'LIKE',
Expand Down Expand Up @@ -376,7 +375,7 @@ public function getCategoryProducts($categoryName, Request $request)
->where('products.isActive', 1)
->whereIn('category_id', $categoriesToSearch)
->whereNotNull('categories.id_parent')
->paginate(6, ['*'], 'page', $request->page ?? 1);
->paginate(15, ['*'], 'page', $request->page ?? 1);


$products = $this->formatProducts($paginatedProducts, true);
Expand Down
2 changes: 2 additions & 0 deletions Fitmo_frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import "@vueup/vue-quill/dist/vue-quill.core.css";

import {
faAngleDown,
faAngleLeft,
faBars,
faCheck,
faFile,
Expand All @@ -37,6 +38,7 @@ library.add(faXmark);
library.add(faStar);
library.add(faCheck);
library.add(faAngleDown);
library.add(faAngleLeft);
library.add(faStar);
library.add(faSignOut);
library.add(faSpinner);
Expand Down
Loading

0 comments on commit f16d1cf

Please sign in to comment.