I am looping through a DB of users to pass data to an API to validate addresses via getAsync. I need to update my DB record based on what the API returns. Problem is that I can't figure out how to pass $user->id to the promise to update the record.
$users = User::all();
$client = new Client();
$promises = (function () use ($users, $client) {
   foreach ($users as $user) {
        yield $client->getAsync('https://some/api/' . $user->address);
    }
})();
$eachPromise = new EachPromise($promises, [
    'concurrency' => 2,
    'fulfilled' => function (Response $response) {
        if ($response->getStatusCode() == 200) {
            //NEED TO ACCESS USER->ID HERE TO UPDATE RECORD IN DB                   
        }
    },
    'rejected' => function ($reason) {
    
    }
]);
$eachPromise->promise()->wait();
Thanks in advance!
