PHP code example of kinatechsolutions / world-data

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

    

kinatechsolutions / world-data example snippets




namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Kinatech\World\Facade\World;

class MyController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function index()
    {

        $postalCodes = World::postalCode()
            ->where('country_code', 'KE')
            ->get();

        $countries = World::country()->get();
        $states = World::state()->get();
        $cities = World::city()->get();
        $languages = World::language()->get();
        $currencies = World::currency()->get();
        
        return response()->json([
            'data' => $postalCodes
        ]);
    }
}
bash
 php artisan migrate
bash
 php artisan world:populate