BadMethodCallException with message 'Call to undefined method Illuminate\Database\Query\Builder::toArray()'

If you want to actually "get" relational data, you don't put parenthesis arount tags. This will work just fine:

$article->tags->toArray();

You put parenthesis when you need to "query" to that collection (Ex. sync, save, attach).

Reference: https://laravel.com/docs/5.1/eloquent-relationships#many-to-many


I had the same problem and solved it by adding get()

For example:

$article->tags()->get()->toArray();

Hope this helps someone :)