PHP code example of deondazy / realaddressfactory

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

    

deondazy / realaddressfactory example snippets


class UserFactory extends Factory
{
    protected $model = User::class;

    public function definition(): array
    {
        /** @var GoogleAddress $address */
        $address = $this->faker->britishAddress();
        
        return [
            'first_name' => $this->faker->firstName(),
            'full_address' => $address->getFormattedAddress(),
            'latitude' => $address->getCoordinates()->getLatitude(),
            'longitude' => $address->getCoordinates()->getLongitude()
        ];
    }
}

use Nonsapiens\RealAddressFactory\RealAddressFactory;

// Generate 20 Johannesburg addresses
$saAddresses = RealAddressFactory::makeSouthAfrica(20, 'Johannesburg');

'brazil' => [
    'cities' => ['Rio de Janeiro', 'São Paulo']
],

$faker->realAddress('Brazil', 'Rio de Janeiro');