Skip to main content

City Service

The City service manages cities within a specific province.

Facade

use JobMetric\Location\Facades\City;

Basic CRUD Operations

Store

Create a new city.

$response = City::store([
'province_id' => 10,
'name' => 'Tehran',
'status' => true,
]);

The name uniqueness is validated within the parent province.

Show

$response = City::show($cityId);

// With relations (if defined)
$response = City::show($cityId, ['province', 'districts']);

Update

$response = City::update($cityId, [
'province_id' => 10,
'name' => 'Tehran (Updated)',
]);

Destroy / Restore / Force Delete

$response = City::destroy($cityId);
$response = City::restore($cityId);
$response = City::forceDelete($cityId);

Toggle Status

$response = City::toggleStatus($cityId);

Querying

// Get all cities for a province
$response = City::all(['province_id' => 10]);