marcreichel / igdb-laravel

Simplify the integration of the IGDB API into your Laravel app. Including IGDB webhook support.
https://marcreichel.dev/docs/igdb-laravel
MIT License
104 stars 22 forks source link

Generate cover Array #43

Closed Xerzzh closed 2 years ago

Xerzzh commented 2 years ago

Hello there,

I'm trying to get a cover list, but I can't get it correctly. If I make a request directly to the IGDB API I can get:

image

But when generating them from the Cover model, I can only get one, if I add several I get error:

syntax error, unexpected ','

Example code:

$cover = Cover::where('game', ($game->id_game_igdb, $game->id_game_igdb))->first();

What am I doing wrong?

Thanks.

marcreichel commented 2 years ago

Hi,

please try

$cover = Cover::whereIn('game', [$id1, $id2, $id3, /* ... */])->first();

instead.

whereIn generates the correct query for your case.

Xerzzh commented 2 years ago

Hi,

please try

$cover = Cover::whereIn('game', [$id1, $id2, $id3, /* ... */])->first();

instead.

whereIn generates the correct query for your case.

Exactly! That was. It works!

Thank you!