marcreichel / igdb-laravel

Simplify the integration of the IGDB API into your Laravel app. Including IGDB webhook support.

Home Page:https://marcreichel.dev/docs/igdb-laravel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Call to a member function contains() on array

oaaron99 opened this issue · comments

I'm just starting to get familiar with using your package and so far everything is good except I have run into an error when trying to combine a select with a where on a basic query.

The following query:

Game::select(['name', 'aggregated_rating_count'])->where('aggregated_rating_count', '>', 5)->get();

Results in this error:

Error: Call to a member function contains() on array in file Builder.php on line 259

I don't know if I am doing something wrong but this query seems fine and follows closely to the examples provided in the README.

It seems the source of the error is that when the fields key exists in the $builder->query collection it is returning an array instead of a collection and then calling $select->contains when $select is an array.

Removing the select or even moving it after the where clause results in a working query.

Both of the following result in no errors:

Game::where('aggregated_rating_count', '>', 5)->get();
Game::where('aggregated_rating_count', '>', 5)->select(['name', 'aggregated_rating_count'])->get();

Any insight would be greatly appreciated

Hey @oaaron99,

thanks for reporting this.

Indeed there was a little bug so the select method returned an array instead of a collection.

The bug is now fixed with the latest version of the package (v2.4.6) in commit aaaf7da.

So feel free to install the latest version to get rid of the bug.
Sorry for the inconvenience.