Skip to main content

Hero Section

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

List Hero Sections

GET /v1/admin/hero-sections

Returns a paginated list of all hero sections.

Response

{
"success": true,
"message": "OK",
"data": {
"current_page": 1,
"first_page_url": "http://192.168.0.139:8080/v1/admin/hero-sections?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http://192.168.0.139:8080/v1/admin/hero-sections?page=1",
"links": [
{
"url": null,
"label": "« السابق",
"active": false
},
{
"url": "http://192.168.0.139:8080/v1/admin/hero-sections?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "التالي »",
"active": false
}
],
"next_page_url": null,
"path": "http://192.168.0.139:8080/v1/admin/hero-sections",
"per_page": 10,
"prev_page_url": null,
"to": 4,
"total": 4,
"hero_sections": [
{
"id": "204bfe40-0ffe-11ee-9bc4-2730b18da1bf",
"title": "Summer Sale",
"description": "Get amazing discounts on all courses",
"active": true,
"is_active_section": true,
"is_active_title": true,
"is_active_description": true,
"is_active_banner": true,
"starts_at": "2024-06-01 00:00:00",
"ends_at": "2024-08-31 23:59:59",
"mobile_image": "http://192.168.0.139:8080/storage/14285/mobile-banner.png",
"web_image": "http://192.168.0.139:8080/storage/14285/web-banner.png",
"button_urls": [
{
"url": "http://example.com/sale",
"title": "Shop Now",
"is_active": true,
"is_main_button": true
}
]
}
]
},
"status_code": 200
}

Create Hero Section

POST /v1/admin/hero-sections

Create a new hero section.

Request Body

ParameterTypeDescriptionValidation Rules
titlestringSection titleRequired if is_active_title is true, 3-255 characters
descriptionstringSection descriptionRequired if is_active_description is true, 3-499 characters
activebooleanActive statusOptional
is_active_sectionbooleanSection active statusOptional
is_active_titlebooleanTitle active statusOptional
is_active_descriptionbooleanDescription active statusOptional
is_active_bannerbooleanBanner active statusOptional
starts_atdatetimeStart date and timeOptional, format: Y-m-d H:i:s
ends_atdatetimeEnd date and timeOptional, after starts_at and current time
mobile_imagefileMobile banner imageRequired, max: 10MB, types: jpeg,png,jpg
web_imagefileWeb banner imageRequired, max: 10MB, types: jpeg,png,jpg
button_urlsarrayArray of button configurationsOptional
button_urls.*.urlstringButton URLRequired with other button fields, valid URL
button_urls.*.titlestringButton textRequired with other button fields, 3-255 characters
button_urls.*.is_activebooleanButton active statusRequired with other button fields
button_urls.*.is_main_buttonbooleanMain button statusRequired with other button fields

Response

{
"success": true,
"message": "تم حفظ البيانات بنجاح.",
"data": {
"id": "2f480800-0591-11f0-b80f-f1005a85de27",
"title": "Summer Sale",
"description": "Get amazing discounts on all courses",
"active": true,
"is_active_section": true,
"is_active_title": true,
"is_active_description": true,
"is_active_banner": true,
"starts_at": "2024-06-01 00:00:00",
"ends_at": "2024-08-31 23:59:59",
"mobile_image": "/storage/29010/mobile-banner.jpg",
"web_image": "/storage/29010/web-banner.jpg",
"button_urls": [
{
"url": "http://example.com/sale",
"title": "Shop Now",
"is_active": true,
"is_main_button": true
}
]
},
"status_code": 200
}

Get Hero Section

GET /v1/admin/hero-sections/{id}

Retrieve details of a specific hero section.

Response

{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": {
"id": "2f480800-0591-11f0-b80f-f1005a85de27",
"title": "Summer Sale",
"description": "Get amazing discounts on all courses",
"active": true,
"is_active_section": true,
"is_active_title": true,
"is_active_description": true,
"is_active_banner": true,
"starts_at": "2024-06-01 00:00:00",
"ends_at": "2024-08-31 23:59:59",
"mobile_image": "/storage/29010/mobile-banner.jpg",
"web_image": "/storage/29010/web-banner.jpg",
"button_urls": [
{
"url": "http://example.com/sale",
"title": "Shop Now",
"is_active": true,
"is_main_button": true
}
]
},
"status_code": 200
}

Update Hero Section

PATCH /v1/admin/hero-sections/{id}

Update an existing hero section.

Request Body

ParameterTypeDescriptionValidation Rules
titlestringSection titleOptional, 3-255 characters
descriptionstringSection descriptionOptional, 3-499 characters
activebooleanActive statusOptional
is_active_sectionbooleanSection active statusOptional
is_active_titlebooleanTitle active statusOptional
is_active_descriptionbooleanDescription active statusOptional
is_active_bannerbooleanBanner active statusOptional
starts_atdatetimeStart date and timeOptional, format: Y-m-d H:i:s
ends_atdatetimeEnd date and timeOptional, after starts_at and current time
mobile_imagefileMobile banner imageOptional, max: 10MB, types: jpeg,png,jpg
web_imagefileWeb banner imageOptional, max: 10MB, types: jpeg,png,jpg
button_urlsarrayArray of button configurationsOptional
button_urls.*.urlstringButton URLRequired with other button fields, valid URL
button_urls.*.titlestringButton textRequired with other button fields, 3-255 characters
button_urls.*.is_activebooleanButton active statusRequired with other button fields
button_urls.*.is_main_buttonbooleanMain button statusRequired with other button fields

Response

{
"success": true,
"message": "تم تحديث البيانات بنجاح.",
"data": {
"id": "2f480800-0591-11f0-b80f-f1005a85de27",
"title": "Updated Summer Sale",
"description": "Updated description",
"active": true,
"is_active_section": true,
"is_active_title": true,
"is_active_description": true,
"is_active_banner": true,
"starts_at": "2024-06-01 00:00:00",
"ends_at": "2024-08-31 23:59:59",
"mobile_image": "/storage/29010/mobile-banner.jpg",
"web_image": "/storage/29010/web-banner.jpg",
"button_urls": [
{
"url": "http://example.com/updated-sale",
"title": "Shop Now",
"is_active": true,
"is_main_button": true
}
]
},
"status_code": 200
}

Bulk Update Hero Sections

PATCH /v1/admin/hero-sections

Update or delete multiple hero sections at once.

Request Body

ParameterTypeDescriptionValidation Rules
idsarrayArray of hero section UUIDs to updateRequired
ids.*stringUUID formatRequired
activebooleanSet active status for all sectionsOptional, true/false
deletebooleanDelete all specified sectionsOptional, true/false

Response

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

Delete Hero Sections

DELETE /v1/admin/hero-sections

Delete one or more hero sections.

Request Body

ParameterTypeDescriptionValidation Rules
idsarrayArray of hero section UUIDs to deleteRequired
ids.*stringUUID formatRequired
confirm_deletionbooleanSet to true for permanent deletionOptional

Response

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

Notes

  • All image files must be in supported formats (JPEG, PNG, JPG) and less than 10MB in size
  • The ends_at date must be after both the starts_at date and the current time
  • Button configurations require all related fields to be present when any button field is provided
  • Soft deletion is supported for hero sections, with the option for permanent deletion using the confirm_deletion parameter