Return the primary keys from models collection

Did you know modelsKeys() Eloquent Collection method? It returns the primary keys from Collection of Model objects.

$users = User::active()->limit(3)->get();
 
$users->modelsKeys(); // [1, 2, 3]

Tip given by @iamharis010

Recent New Courses