<?php

namespace App\Repositories\Core;

class Geolocation
{
    public static function getCoords($address, $zipcode, $city)
    {
        if (! ($address && $zipcode && $city)) {
            return;
        }
        $address .= ' , '.$city.' '.$zipcode.' , France';

        $geocode = app('geocoder')->geocode($address)->get();

        if (! count($geocode)) {
            return false;
        }
        $res = $geocode[0]->getCoordinates()->toArray();
        $longitude = $res[0];
        $latitude = $res[1];

        return ['latitude' => $latitude, 'longitude' => $longitude];
    }

    public static function autocomplete($query)
    {
    }
}
