В запросе SQL я хочу добавить оператор if. если широта и долгота в базе данных равны нулю, запрос будет выполнен и заполнит значение в базе данных
$users = DB::table('users',IF ($user->lat && $user->lng == Null))->get();
foreach ($users as $user)
{
$response = Geocode::make()->address($user->zipcode);
if ($response) {
$lat = $response->latitude();
$lng = $response->longitude();
$city = $response->formattedAddress();
echo $response->locationType();
DB::table('users')
->where('id', $user->id)
->update(['lat' => $lat,'lng' => $lng,'city' => $city]);
}
}