It helps to retrieve array for a given key.
$categories = Category::where('is_popular',1)->pluck('id');
Example above, fetches list of category ids only which have is_popular fields is set to 1.
Then, we can use count with the chain since laravel collection supports it, if we want to get number of returned categories.. like following.
$categories = Category::where('is_popular',1)->pluck('id')->count();
In above snippet if we chain count() to toArray() which is another collection method then count will not work since toArray returns plain php and collection only work on returned eloquent objects.
$categories = Category::where('is_popular',1)->pluck('id')->toArray()->count(); // this will not work.. will show this error - Call to a member function count() on array
Lastly, if we want to get list of category ids and names as key value pair, we can use pluck() method in following way.
$categories = Category::where('is_popular',1)->pluck( 'name' ,'id'); // first parameter is the name of the field and second parameter is the key