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

How to get the company logo #38

Closed Askancy closed 3 years ago

Askancy commented 3 years ago

Hi I would need to receive the publisher/developer logo, I currently have the query:

        $game = Game::with(['cover' => ['url', 'image_id'],
        'screenshots' => ['url', 'image_id','height','width'],
        'artworks' => ['url', 'image_id'],
        'videos' => ['video_id', 'name'],
        'involved_companies', 'involved_companies.company'
        ])->where('slug', $value)->first();

I get this Company, for example:

Immagine

as you can see in the logo I have the id “1354”. reading the documentation I found company_logos, but I don't understand how to use it.

I tried adding: 'company_logos' => ['url', 'image_id.company']

could you give me an example of how can I get the url of the logo? thank you very much

marcreichel commented 3 years ago

Hi @Askancy,

there was a little bug in version 2.4.3 for generating where clauses. You may update to the latest version to get rid of the bug 👍🏼

To get the logo url of a company simply add the logo to the expand (with) clause like this:

$game = Game::with([
    'cover' => ['url', 'image_id'],
    'screenshots' => ['url', 'image_id','height','width'],
    'artworks' => ['url', 'image_id'],
    'videos' => ['video_id', 'name'],
    'involved_companies',
    'involved_companies.company',
+   'involved_companies.company.logo',
])->where('slug', $value)->first();