PHP code example of yomo / addressfactory

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

    

yomo / addressfactory example snippets


Yomo\AddressFactory\AddressFactoryServiceProvider::class

use Faker\Generator as Faker;

$factory->define( \App\Models\Business::class, function ( Faker $faker ) {

	/** @var \Geocoder\Provider\GoogleMaps\Model\GoogleAddress $address */
	$address = $faker->britishAddress();

	return [

		'title'              => $faker->words(2),
		'full_address'       => $address->getFormattedAddress(),
		'latitude'           => $address->getCoordinates()->getLatitude(),
		'longitude'          => $address->getCoordinates()->getLongitude()

	];

} );

	$address = $faker->realAddress('Brazil')						# From any of the defined cities
	$address = $faker->realAddress('Brazil', 'Rio de Janiero');		# For Rio de Janiero only
	$address = $faker->realAddresss('Brazil', ['Rio de Janiero', 'Salvador'])	# Multiple cities

use Yomo\AddressFactory\Facades\RealAddress;
.
.
.
$johannesburgAddresses 	= RealAddress::makeSouthAfrica(20, 'Johannesburg');		# 20 addresses for Johannesburg, South Africa
$frenchAddress 			= RealAddress::makeFrance(1);							# A single address for France
$brazilAddresses		= RealAddress::make(10, 'Brazil');						# 10 addresses for the custom country of Brazil

$f = new \Yomo\AddressFactory\RealAddress();

$southAfricanPoints = $f->makeSouthAfrica(4);                # Generates 4 locations within South Africa's major cities
$capeTownPoints     = $f->makeSouthAfrica(2, 'Cape Town');   # Generates 2 locations from Cape Town, South Africa
$multiPoints        = $f->makeSouthAfrica(3, ['Pretoria', 'Johannesburg']);

'kenya' => [
		'cities' => [ 'Nairobi', 'Mombasa' ],
	],

php artisan vendor:publish --tag=yomo.realaddress
bash
php artisan vendor:publish --tag=yomo.realaddress