collect only id not all data laravel code example
Example 1: add to collection laravel
$item = collect();
$item->push($product);
Example 2: pluck laravel
$name = DB::table('users')->where('name', 'John')->pluck('name');
$item = collect();
$item->push($product);
$name = DB::table('users')->where('name', 'John')->pluck('name');