mirror of
https://github.com/openclassify/openclassify.git
synced 2026-04-14 11:12:09 -05:00
24 lines
723 B
PHP
24 lines
723 B
PHP
<?php
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
Route::get('/locations/cities/{country}', function(\Modules\Location\Models\Country $country) {
|
|
$activeCities = $country->cities()
|
|
->where('is_active', true)
|
|
->orderBy('name')
|
|
->get(['id', 'name', 'country_id']);
|
|
|
|
if ($activeCities->isNotEmpty()) {
|
|
return response()->json($activeCities);
|
|
}
|
|
|
|
return response()->json(
|
|
$country->cities()
|
|
->orderBy('name')
|
|
->get(['id', 'name', 'country_id'])
|
|
);
|
|
})->name('locations.cities');
|
|
|
|
Route::get('/locations/districts/{city}', function(\Modules\Location\Models\City $city) {
|
|
return response()->json($city->districts);
|
|
})->name('locations.districts');
|