1. Go to this page and download the library: Download aestheticraza/laravelglobe 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/ */
aestheticraza / laravelglobe example snippets
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Aestheticraza\LaravelGlobe\Traits\HasLocation;
class Order extends Model
{
use HasLocation;
}
$order = Order::find(1);
// Standard Relational Lookups
echo $order->country->name; // e.g. "Pakistan"
echo $order->state->name; // e.g. "Punjab"
echo $order->city->name; // e.g. "Lahore"
// Dynamic Virtual Accessors (Provided by the Trait)
echo $order->full_address; // "Lahore, Punjab, Pakistan"
echo $order->country->emoji; // "🇵🇰"
echo $order->country->phone_code; // "+92"
// Fetch all "active" delivery riders within 25 KM of a customer's drop-off coordinates
$ridersNearMe = Rider::where('status', 'active')
->withinRadius($customerLat, $customerLng, 25)
->get();
// Find the closest branch of a restaurant chain natively!
$closestBranch = RestaurantBranch::withinRadius(31.5204, 74.3587, 10)->first();
use Aestheticraza\LaravelGlobe\Models\Country;
$country = Country::where('iso2', 'US')->first();
// Loop through all Official Timezones for the USA (EST, PST, CST, MST, etc.)
foreach ($country->timezones as $timezone) {
echo $timezone->zone_name . ' (' . $timezone->abbreviation . ')' . PHP_EOL;
}
// Loop through officially accepted Currencies (e.g. Panama uses PAB and USD)
$panama = Country::where('iso2', 'PA')->first();
foreach ($panama->currencies as $currency) {
echo $currency->code . ' - ' . $currency->symbol;
}