1. Go to this page and download the library: Download flairuk/laravel-cities 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/ */
flairuk / laravel-cities example snippets
use FLAIRUK\Cities\Facades\Cities;
Cities::find('lon'); // City { id: 4241, code: "LON", name: "London", countryCode: "GB" }
Cities::findOrFail('LON'); // throws ItemNotFoundException for unknown codes
Cities::exists('NYC'); // true
Cities::findById(4241);
Cities::all(); // Collection<string, City> keyed by code
Cities::inCountry('FR'); // cities in France
Cities::search('london'); // matches on name or exact code
Cities::codes();
Cities::options(); // ['LON' => 'London', ...] sorted by name
Cities::options('id'); // [4241 => 'London', ...]
use FLAIRUK\Cities\Rules\CityCode;
$request->validate(['city' => ['