PHP code example of winter / wn-location-plugin

1. Go to this page and download the library: Download winter/wn-location-plugin 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/ */

    

winter / wn-location-plugin example snippets


$table->integer('country_id')->unsigned()->nullable()->index();
$table->integer('state_id')->unsigned()->nullable()->index();

public $implement = ['Winter.Location.Behaviors.LocationModel'];

// Softly looks up and sets the country_id and state_id
// for these Country and State relations.

$model->country_code = "US";
$model->state_code = "FL";
$model->save();

$usCountry = \Winter\Location\Models\Country::whereCode('US')->first();

$usCountry->iso_name;
// (string) "United States of America"

$usCountry->iso_alpha3;
// (string) "USA"

$usCountry->iso_numeric;
// (string) "840"

$usCountry->iso_currencies;
// (array) [ 0 => "USD" ]

$usCountry->iso;
// (array) [
//     "name" => "United States of America"
//     "alpha2" => "US"
//     "alpha3" => "USA"
//     "numeric" => "840"
//     "currency" => [
//         0 => "USD"
//     ]
// ]

bash
php artisan migrate