Skip to main content

StoreGeoAreaRequest

Form request class for validating GeoArea creation data.

Namespace

JobMetric\Location\Http\Requests\GeoArea\StoreGeoAreaRequest

Overview

Geo areas are reusable groupings of multiple locations.

Key features validated by this request:

  • translation is required and must include at least one locale with a name
  • Optional locations array supports location tuples
  • Duplicate locations inside the payload are rejected

Validation Rules

Required Fields

FieldRuleDescription
translationrequired|arrayTranslation map
translation.*.namerequired|string|max:255Geo area name

Optional Fields

FieldRuleDescription
translation.*.descriptionnullable|stringOptional description
statussometimes|booleanEnabled/disabled
locationsnullable|arrayList of location tuples
locations.*.country_idrequired|integer|exists:{countries},idCountry id
locations.*.province_idnullable|integer|exists:{provinces},idProvince id
locations.*.city_idnullable|integer|exists:{cities},idCity id
locations.*.district_idnullable|integer|exists:{districts},idDistrict id

Duplicate locations check

The request rejects duplicates based on the tuple (country_id, province_id, city_id, district_id) within the locations array.

Usage Example

use JobMetric\Location\Facades\GeoArea;

$response = GeoArea::store([
'translation' => [
'en' => [
'name' => 'Tehran Zone',
'description' => 'All supported districts in Tehran.',
],
],
'status' => true,
'locations' => [
['country_id' => 1, 'province_id' => 10, 'city_id' => 120],
['country_id' => 1, 'province_id' => 10, 'city_id' => 120, 'district_id' => 900],
],
]);