Product Setup Module

Category Management

Complete documentation for category setup, hierarchy, API endpoints, validation rules, and UI behavior.

Overview

Category Management is used to organize products into parent-child groups. Each category can have a title, optional image, parent category, and active/inactive status.

Backend Structure

  • routes/api.php - Category route declarations
  • app/Http/Controllers/Api/CategoryController.php - Request handling and service delegation
  • app/Services/Api/CategoryService.php - Business logic (list/create/update/delete/status)
  • app/Http/Requests/Api/Category/* - Validation rules
  • app/Models/Category.php - Model + parent/children/product relationships

API Endpoints

Method Endpoint Purpose
GET/api/v1/categoriesList categories with pagination, filters, and parent relation
POST/api/v1/category/storeCreate category
ANY/api/v1/category/update/{id}Update category
ANY/api/v1/category/update-status/{id}Update single category status
POST/api/v1/category/status-update/multipleBulk status update
DELETE/api/v1/category/delete/{id}Delete single category
DELETE/api/v1/category/multiple-deleteDelete multiple categories

Request Rules

Create and Update

  • title: required, max 255, unique per company
  • image: optional image file (png, jpg, jpeg, gif, webp)
  • status: optional (converted to 1/0 internally)
  • parentId: optional existing category id

Status Update

  • status: required, allowed values 0 or 1

Bulk Status Update

  • ids: required array, every id must exist in categories
  • status: required, allowed values 0 or 1

Bulk Delete

  • ids: required for bulk delete, must be an array of existing category ids

Filtering and List Response

GET /api/v1/categories supports these query params:

  • page, perPage
  • search (title search)
  • status
  • filterParentCategory
  • sortField, sortOrder

Response includes data, meta, and others_data (all categories + parent-only categories).

Frontend

Main UI component: frontend-source/src/pages/product-setup/category/Category.jsx

  • Search and advanced filtering
  • Parent category selection
  • Status toggle and bulk operations
  • Create/edit modal with image upload
  • Role-based action controls

Screenshots

Category Create Screen
Category create form

Troubleshooting

Issue Likely Cause Fix
Cannot create categoryDuplicate title in same companyUse a unique title
Image not savedInvalid formatUpload png/jpg/jpeg/gif/webp
Bulk status update failsInvalid category id in idsSend existing ids only
Parent category not availableInvalid parentId or access scope mismatchPick a valid category from same company scope