PHP code example of zarbinco / laravel-iran-locations
1. Go to this page and download the library: Download zarbinco/laravel-iran-locations library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zarbinco / laravel-iran-locations example snippets
use Zarbin\IranLocations\Contracts\LocationReadRepository;
final class LocationController
{
public function __construct(
private readonly LocationReadRepository $locations,
) {}
public function cities()
{
return $this->locations->options('cities', [
'province_code' => 'p.01',
]);
}
}
use Zarbin\IranLocations\Models\City;
use Zarbin\IranLocations\Models\CityRegion;
use Zarbin\IranLocations\Models\Neighborhood;
use Zarbin\IranLocations\Models\Province;
$province = Province::query()->byCode('p.01')->first();
$cities = City::query()
->forProvince($province)
->active()
->ordered()
->get();
$regions = CityRegion::query()
->forCityCode('s.01.01.01.01')
->orderedByNumber()
->get();
$neighborhoods = Neighborhood::query()
->forRegionCode('r.01.01.01.01.05')
->ordered()
->get();