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
| Parameter | Type | Description |
|---|---|---|
search_text | string | Search in category names |
filter[available] | boolean | Filter by availability status |
filter[name] | string | Filter by exact name match |
sort | string | Sort by: name, priority, available |
per_page | integer | Number of items per page (default: 10) |
list | boolean | Return 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
| Parameter | Type | Description |
|---|---|---|
name | string | Required. Category name (3-255 characters) |
available | boolean | Required. Category availability status |
priority | integer | Optional. Category display priority (> 0) |
parent_category_id | string | Optional. UUID of parent category |
description | string | Optional. 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
| Parameter | Type | Description |
|---|---|---|
name | string | Optional. Category name (3-255 characters) |
available | boolean | Optional. Category availability status |
priority | integer | Optional. Category display priority (> 0) |
parent_category_id | string | Optional. UUID of parent category |
description | string | Optional. 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
| Parameter | Type | Description |
|---|---|---|
ids | array | Required. Array of category UUIDs to delete |
ids.* | string | Required. 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