The modelKeys method returns the primary keys for all models in the collection:
modelKeys
$users->modelKeys(); // [1, 2, 3, 4, 5]