We participate in the Amazon Service LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com

Laravel Eloquent only()
$fullModel = Model::find(1) // Get model with id 1
$idArray = $fullModel->only('id')  // array containing id

// this does not work. You'll get back an empty collection
// It is trying to pull the id column off the collection object,
// not the models it contains
$models = Model::all()
$ids = $models->only('id')

// this will give you a collection of ids
$models = Model::all()
$ids = $models->pluck('id')