"No provider registered " 在 laravel 中使用地理编码包时发生错误
"No provider registered " error occure using geocode packages in laravel
https://github.com/geocoder-php/GeocoderLaravel/blob/master/config/geocoder.php I cant get pass this point. 1. this is my Job
public $model;
public function __construct($model)
{
$this->model = $model;
}
public function handle()
{
$result = new Geocoder();
$result->geocode($this->model->getAddressString());
// $result = Geocoder::geocode($this->model->getAddressString());
$this->model->setCoordinates($result->getLatitude(), $result->getLongitude());
}
}
I followed the instructions in the repo readme to install geocoder into my project.
2. this is my controller
在尝试从地址获取纬度和纬度时,我收到了没有提供商注册的错误。
protected function create(array $data)
{
$user = User::create([
'fname' => $data['fname'],
'lname' => $data['lname'],
'email' => $data['email'],
'zipcode' => $data['zipcode'],
'address_latitude' => $data['address_latitude'],
'address_longitude' =>$data['address_longitude'],
'password' => Hash::make($data['password']),
'gender' => $data['gender'],
'dob' => $data['dob'],
'health' => $data['health'],
]);
//$this-> dispatch(new GeocodePartnerAddress($user));
$this->dispatch(new GeocodeAddress($user));
}
在尝试从地址获取纬度和纬度时,我收到了没有提供商注册的错误。
I followed the instructions in the repo readme to install geocoder into my project.
我得到 "No provider registered." 这个错误如果你做这个问题请给我解决我错的地方。
public function handle()
{
$users = User::whereNull('lat')->whereNull('lng')->whereNull('city')->whereNull('state')->whereNull('address')->get();
foreach ($users as $user)
{
$response = Geocode::make()->address($user->zipcode);
if ($response){
$lat = $response->latitude();
$lng = $response->longitude();
$city = $response->raw()->address_components[1]->long_name;
$state = $response->raw()->address_components[2]->long_name;
$address = $response->formattedAddress();
echo $response->locationType();
DB::table('users')->where('id', $user->id)->update(['lat' => $lat, 'lng' => $lng, 'city' => $city, 'state' => $state, 'address'=> $address]);
}
}exit;
}
https://github.com/geocoder-php/GeocoderLaravel/blob/master/config/geocoder.php I cant get pass this point. 1. this is my Job
public $model;
public function __construct($model)
{
$this->model = $model;
}
public function handle()
{
$result = new Geocoder();
$result->geocode($this->model->getAddressString());
// $result = Geocoder::geocode($this->model->getAddressString());
$this->model->setCoordinates($result->getLatitude(), $result->getLongitude());
}
}
I followed the instructions in the repo readme to install geocoder into my project.
2. this is my controller
在尝试从地址获取纬度和纬度时,我收到了没有提供商注册的错误。
protected function create(array $data)
{
$user = User::create([
'fname' => $data['fname'],
'lname' => $data['lname'],
'email' => $data['email'],
'zipcode' => $data['zipcode'],
'address_latitude' => $data['address_latitude'],
'address_longitude' =>$data['address_longitude'],
'password' => Hash::make($data['password']),
'gender' => $data['gender'],
'dob' => $data['dob'],
'health' => $data['health'],
]);
//$this-> dispatch(new GeocodePartnerAddress($user));
$this->dispatch(new GeocodeAddress($user));
}
在尝试从地址获取纬度和纬度时,我收到了没有提供商注册的错误。
I followed the instructions in the repo readme to install geocoder into my project.
我得到 "No provider registered." 这个错误如果你做这个问题请给我解决我错的地方。
public function handle()
{
$users = User::whereNull('lat')->whereNull('lng')->whereNull('city')->whereNull('state')->whereNull('address')->get();
foreach ($users as $user)
{
$response = Geocode::make()->address($user->zipcode);
if ($response){
$lat = $response->latitude();
$lng = $response->longitude();
$city = $response->raw()->address_components[1]->long_name;
$state = $response->raw()->address_components[2]->long_name;
$address = $response->formattedAddress();
echo $response->locationType();
DB::table('users')->where('id', $user->id)->update(['lat' => $lat, 'lng' => $lng, 'city' => $city, 'state' => $state, 'address'=> $address]);
}
}exit;
}