PHP code example of urameshibr / brazilcities

1. Go to this page and download the library: Download urameshibr/brazilcities 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/ */

    

urameshibr / brazilcities example snippets


// file START ommited
'providers' => [
    // other providers ommited
    Urameshibr\Providers\CityServiceProvider::class,
],
// file END ommited



namespace Urameshibr;

use Illuminate\Database\Eloquent\Model;

class City extends Model{

    public $timestamps = false;

    protected $fillable = ['name', 'uf'];
}

Route::get('/ufs/', function($uf = null){
    return response()->json(\Urameshibr\City::select('uf')->distinct('uf')->orderBy('uf')->get());
});

Route::get('/cities/{uf}', function($uf = null){
    return response()->json(\Urameshibr\City::where('uf', $uf)->orderBy('name')->get());
});
sh
$ composer dump-auto
$ php artisan migrate
$ php artisan db:seed --class="CitySeeder"