#database #development #eloquent #laravel #php

Did you know that in Laravel there was a method called getRelatedIds on the belongs to many relationship?

It was renamed to allRelatedIds and it can be used as an alternative to pluck('id') to get all of the IDs for the related models.

1// instead of
2$article->tags()->pluck('id')->toArray();
3
4// you can use
5$article->tags()->allRelatedIds()->toArray();