Laravel - Collections - Method ModelKeys

The modelKeys method returns the primary keys for all models in the collection:

    
    $users->modelKeys();
    
    // [1, 2, 3, 4, 5]