Skip to main content

Categories

This section covers the API endpoints for managing categories in the admin panel.

List Categories

GET /v1/admin/categories

Returns a paginated list of all categories.

Query Parameters

ParameterTypeDescription
search_textstringSearch in category names
filter[available]booleanFilter by availability status
filter[name]stringFilter by exact name match
sortstringSort by: name, priority, available
per_pageintegerNumber of items per page (default: 10)
listbooleanReturn simplified list format

Response

{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": {
"current_page": 1,
"first_page_url": "http://testing-api.sumaya369.net/v1/admin/categories?sort=priority&page=1",
"from": 1,
"last_page": 3,
"last_page_url": "http://testing-api.sumaya369.net/v1/admin/categories?sort=priority&page=3",
"links": [
{
"url": null,
"label": "« السابق",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/categories?sort=priority&page=1",
"label": "1",
"active": true
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/categories?sort=priority&page=2",
"label": "2",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/categories?sort=priority&page=3",
"label": "3",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/categories?sort=priority&page=2",
"label": "التالي »",
"active": false
}
],
"next_page_url": "http://testing-api.sumaya369.net/v1/admin/categories?sort=priority&page=2",
"path": "http://testing-api.sumaya369.net/v1/admin/categories",
"per_page": 10,
"prev_page_url": null,
"to": 10,
"total": 29,
"categories": [
{
"id": "eb8fec80-b43f-11ec-8195-abf33b22a6c8",
"name": "مواد الشهر",
"available": true,
"priority": 1,
"parent_category_id": null,
"parent_category_name": null,
"description": "المواد المتاحة لهذا الشهر",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00"
},
{
"id": "e4e0bb10-db44-11ec-91f3-dff7c0899e8e",
"name": "المواد المتاحة للاشتراك",
"available": true,
"priority": 2,
"parent_category_id": null,
"parent_category_name": null,
"description": "null",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00"
},
{
"id": "265f31ad-1b4e-355f-844a-af92d88de7b0",
"name": "نية الثراء",
"available": true,
"priority": 3,
"parent_category_id": null,
"parent_category_name": null,
"description": "null",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00"
},
{
"id": "a0c9414c-c43b-3916-91e5-4a95bd9e4908",
"name": "نية النجاح",
"available": true,
"priority": 4,
"parent_category_id": null,
"parent_category_name": null,
"description": "null",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00"
},
{
"id": "6c83f3c0-c80a-11ef-ad11-d9dd3176ea73",
"name": "تصنيف جديد",
"available": true,
"priority": 5,
"parent_category_id": null,
"parent_category_name": null,
"description": "null",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00"
},
{
"id": "b55070c4-144c-3ceb-a8e6-2edf7dd9e740",
"name": "نية الروحانية",
"available": true,
"priority": 5,
"parent_category_id": null,
"parent_category_name": null,
"description": "null",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00"
},
{
"id": "e0dda9cc-1cb1-3d46-b49b-97858afb9c0b",
"name": "عالم الأثير",
"available": false,
"priority": 6,
"parent_category_id": null,
"parent_category_name": null,
"description": null,
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00"
},
{
"id": "47cd4b03-e2fb-38db-8d4b-9d3cfa2f565f",
"name": "نية الحظ",
"available": true,
"priority": 6,
"parent_category_id": null,
"parent_category_name": null,
"description": "خحهخحكخهنمك",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00"
},
{
"id": "4f8d8f17-c6fe-3086-8886-698d27f5c0ee",
"name": "القوانين الكونية",
"available": false,
"priority": 7,
"parent_category_id": null,
"parent_category_name": null,
"description": null,
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00"
},
{
"id": "5e4597a3-1f56-332b-9933-7c60c9f049dc",
"name": "نية تشافي العلاقات",
"available": true,
"priority": 7,
"parent_category_id": null,
"parent_category_name": null,
"description": "null",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00"
}
]
},
"status_code": 200
}

Create Category

POST /v1/admin/categories

Create a new category.

Request Body

ParameterTypeDescription
namestringRequired. Category name (3-255 characters)
availablebooleanRequired. Category availability status
priorityintegerOptional. Category display priority (> 0)
parent_category_idstringOptional. UUID of parent category
descriptionstringOptional. Category description

Response

{
"success": true,
"message": "تم حفظ البيانات بنجاح.",
"data": {
"id": "3f8d8a80-07e8-11f0-961b-e9946ba2e6d7",
"name": "dddd22",
"available": false,
"description": "dsdf",
"priority": 50,
"parent_category": null,
"created_at": "2025-03-23 16:10:52",
"updated_at": "2025-03-23 16:10:52"
},
"status_code": 200
}

Get Category

GET /v1/admin/categories/{id}

Retrieve details of a specific category.

Response

{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": {
"id": "eb8fec80-b43f-11ec-8195-abf33b22a6c8",
"name": "مواد الشهر",
"available": true,
"description": "المواد المتاحة لهذا الشهر",
"priority": 1,
"parent_category": null,
"created_at": "2022-04-04 20:51:56",
"updated_at": "2024-12-23 10:15:17"
},
"status_code": 200
}

Update Category

PATCH /v1/admin/categories/{id}

Update an existing category.

Request Body

ParameterTypeDescription
namestringOptional. Category name (3-255 characters)
availablebooleanOptional. Category availability status
priorityintegerOptional. Category display priority (> 0)
parent_category_idstringOptional. UUID of parent category
descriptionstringOptional. Category description

Response

{
"success": true,
"message": "تم تحديث البيانات بنجاح.",
"data": {
"id": "3f8d8a80-07e8-11f0-961b-e9946ba2e6d7",
"name": "نية الثراء 2",
"available": false,
"description": "dsdf",
"priority": 50,
"parent_category": null,
"created_at": "2025-03-23 16:10:52",
"updated_at": "2025-03-23 16:11:44"
},
"status_code": 200
}

Delete Categories

DELETE /v1/admin/categories

Delete one or more categories.

Request Body

ParameterTypeDescription
idsarrayRequired. Array of category UUIDs to delete
ids.*stringRequired. UUID format

Response

{
"success": true,
"message": "تم حذف البيانات بنجاح.",
"data": null,
"status_code": 200
}

Authorization

All category endpoints require admin authorization. The user must have the appropriate permissions to perform these operations.

Notes

  • When deleting categories, any child categories will have their parent_category_id set to null
  • Category names must be unique
  • Default sorting is by priority in ascending order
  • The list parameter returns all categories without pagination for dropdown menus