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

Game cover give me an array instead an object #73

Closed pirmax closed 1 year ago

pirmax commented 1 year ago

Hey,

The following code (presented on docs) :

$game = Game::where('name', 'Fortnite')
            ->with(['cover'])
            ->first();

dd($game->cover->getUrl(Size::COVER_BIG));

The cover attribute is an array and not an object to use getUrl() method...

What did I do wrong? Thanks.

marcreichel commented 1 year ago

@pirmax

I've added the missing cast to the cover object.

The fix is released in version 3.8.1.

Please update and check again. If it's not working then please let me know here.

captenmasin commented 1 year ago

Hi I'm on 3.8.1 and I'm also getting an array with ->cover

$game = Game::where('name', 'Fortnite')->with(['cover'])->first();
dd($game->cover);
array:9 [▼ // app/Actions/Home.php:26
  "id" => 112205
  "alpha_channel" => false
  "animated" => false
  "game" => 1905
  "height" => 800
  "image_id" => "co2ekt"
  "url" => "//images.igdb.com/igdb/image/upload/t_thumb/co2ekt.jpg"
  "width" => 600
  "checksum" => "c75e6a90-832c-6d15-8839-6732f415cabe"
]
marcreichel commented 1 year ago

@captenmasin Fixed with version 4.0.0. It's a major release, because the minimum PHP version is bumped to PHP 8.1.

Please update to that release and check again.

captenmasin commented 1 year ago

Aaay it's working! Very nice, much appreciated