Skip to main content

LocationResource

JSON resource class for transforming Location models into structured API responses.

Namespace

JobMetric\Location\Http\Resources\LocationResource

Overview

Locations represent unique tuples of (country, province, city, district). The resource includes ids and can optionally include related models when loaded.

Base Properties

PropertyTypeDescription
idintLocation ID
country_idintCountry id
province_idint|nullProvince id
city_idint|nullCity id
district_idint|nullDistrict id
created_atmixedCreated timestamp (as provided by the model)

Conditional Properties

PropertyRelationType
countrycountryCountryResource
provinceprovinceProvinceResource
citycityCityResource
districtdistrictDistrictResource
location_relationslocationRelationsmixed

Usage Example

use JobMetric\Location\Http\Resources\LocationResource;
use JobMetric\Location\Models\Location;

$location = Location::with(['country', 'province', 'city', 'district'])->find(1);

return LocationResource::make($location);