Let's say I've got an Article
s collection, and I want to fetch the popular articles.
So first, I make a scopePopular()
method in the Article
method. Very simple.
Now I want to fetch their id
s, so I'll do this:
Article::popular->pluck('id');
The result will be an associative array:
[
0 => 1,
1 => 34,
2 => 17
...
];
I want to get a normal array, without the keys, Like:
[1, 34, 17]
I know I can just do something like this:
array_values(Article::popular->pluck('id'));
But I believe Laravel has much more cleaner way to do this. Any ideas?