Skip to main content

GeoAreaResource

JSON resource class for transforming GeoArea models into structured API responses. Supports translations and location mapping.

Namespace

JobMetric\Location\Http\Resources\GeoAreaResource

Overview

Geo areas represent a logical area that can be associated with one or more locations. This resource supports:

  • Translation output via TranslationCollectionResource (only when translations relation is loaded)
  • Location mapping via locationRelations (and optionally locationRelations.location for full location objects)

Base Properties

PropertyTypeDescription
idintGeo area ID
statusboolEnabled/disabled
deleted_atstring|nullISO 8601 deletion timestamp
created_atstring|nullISO 8601 creation timestamp
updated_atstring|nullISO 8601 update timestamp

Conditional Properties

PropertyRelationTypeNotes
translationstranslationsobjectTranslationCollectionResource::make($this)->withLocale(app()->getLocale())
locationslocationRelationsarrayEach item is either a LocationResource (when location relation on each relation row is loaded) or { "location_id": int }

Usage Examples

Basic usage

use JobMetric\Location\Http\Resources\GeoAreaResource;
use JobMetric\Location\Models\GeoArea;

$geoArea = GeoArea::find(1);

return GeoAreaResource::make($geoArea);

With translations and locations

$geoArea = GeoArea::with([
'translations',
'locationRelations.location.country',
'locationRelations.location.province',
'locationRelations.location.city',
'locationRelations.location.district',
])->find(1);

return GeoAreaResource::make($geoArea);

Response Example (simplified)

{
"id": 1,
"translations": {
"en": {
"name": "Tehran Zone",
"description": "All supported districts in Tehran."
}
},
"status": true,
"deleted_at": null,
"created_at": "2026-02-05T12:00:00.000000Z",
"updated_at": "2026-02-05T12:00:00.000000Z",
"locations": [
{
"id": 10,
"country_id": 1,
"province_id": 10,
"city_id": 120,
"district_id": null,
"created_at": "2026-02-05T12:00:00.000000Z"
}
]
}