marcreichel / igdb-laravel Goto Github PK
View Code? Open in Web Editor NEWSimplify the integration of the IGDB API into your Laravel app. Including IGDB webhook support.
Home Page: https://marcreichel.dev/docs/igdb-laravel
License: MIT License
Simplify the integration of the IGDB API into your Laravel app. Including IGDB webhook support.
Home Page: https://marcreichel.dev/docs/igdb-laravel
License: MIT License
The following Models are missing:
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:
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.
For some reason i am only able to create Webhooks manually via postman and not through any of the methods you have listed.
This is weird because It was working after my queries last week. Which is why i closed the issues. But for some reason it stopped after taking 2 days off coding.
In my attempt to firefight i updated my client secret. Did this make things worse? Does Igdb-laravel update the bearer access code after this happens?
Also, even after i successfully created a webhook via postman, when i try to test it using the instructions here, i receive the below error.
Error sending test JSON, Webhook url responsed with: 405
There was an update to igdb last week. Was there a change in webhook handling?
How does one go about getting 6 game characters from a game?
Im using at moment:
if ($torrent->category->game_meta) {
$meta = Game::with(['cover' => ['url', 'image_id'], 'artworks' => ['url', 'image_id'], 'genres' => ['name']])->find($torrent->igdb);
}
What I would like to do in my view is display 6 character names and mugshots.
This is what my view is at the moment.
https://pastebin.com/cZ47Sbpd
Thanks for the great package.
- Installation request for marcreichel/igdb-laravel ^0.9.0 -> satisfiable by marcreichel/igdb-laravel[v0.9.0].
- Installation request for laravel/framework (locked at v6.0.3, required as ^6.0) -> satisfiable by laravel/framework[v6.0.3].
Can you push a new release please with your added Laravel 6 support you did 11 days ago?
Hello, I am requesting for next releases games where first_release_date is > now, but I only get 10 objects, this is a limit? thanks!
is it posibble to get a cover bigger? now If i get cover I get one thumbnail 90x90, thanks!
Hello,
first of all, thank you for this wrapper which allows me to work with IGDB more easily.
However, I have a little problem with the relations. I try to sort the games I get by genre but it doesn't work
Here is how I do it
$games = IGDBGame::with(['platforms', 'cover', 'genres']); $games->whereHas('genres', function($query){ $query->where('name', 'platform'); });
I didn't find in your documentation something that does similar
Do you have any idea how to filter a result via a query with your wrapper?
Thanks for everything!
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:
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
Is dot notation supported by this wrapper?
Say I want to search for something like this:
Game where the Twitch ID == 33214 (Fortnite)
fields *; where external_games.category = 14 & external_games.uid = "33214";
Or this:
Games for PS4
fields *; where game.platforms = 48;
I have tried the below but always get NULL:
$igdb = new IGDB('games'); // 'games' is the endpoint
$games = $igdb->where('external_games.category', '14')->where('external_games.uid', 33214)->get();
///////
$games = $igdb->where('game.platforms', '48')->get();
Simpler queries do work, but as soon as I introduce dot notation the result is always null
.
Hello, I seem to be experiencing an issue similar to closed issue #47
The token works perfectly fine for 24 hours, but after a nights sleep and i start my dev server up in the morning it seems to state that the token is invalid, so i'm not sure if its refreshing the token properly?
If i go ahead and type php artisan cache:forget igdb_cache.access_token
Everything works normally again?
I'm running the latest version of Laravel and the latest version igdb-laravel ("marcreichel/igdb-laravel": "^3.5")
I'm fairly new to Laravel and the IGDB API so apologise if i have missed something, however everything has been working perfectly, my project also uses the direct helix twitch api with the same authentication tokens, and those calls still work perfectly on the website so i know the tokens are working correctly and have not been revoked etc.., its just anything related to IGDB requests which use this wrapper.
If you need anything, logs etc.. please let me know, (and where to get them) and ill gladly provide them :)
Thank you.
I'm trying to run the following: $company = Company::find(95000);
. I got the 95000 from a game query in the involved_companies
. Are some company
returns really null
?
I have a really weird issue after the update to 4.1.0. A test with 4.0.0 shows that this issue doesn't exist on this version.
Sometimes I just don't get any output. No error, nothing. I have a script to update game info and this just gets the data via IGDB-IDs. Most of the time it works just fine but sometimes it doesn't. I tried to replicate this issue with Tinkerwell but I'm still not 100% sure what is happening. But at the end of the issue is a video that shows the issue.
I have an array with 431 IDs. Neither the number nor the exakt ID seems to be an issue, as I get this behavior with multiple configurations. Even when I only take 300 the error is there and is not if I delete the last one that shouldn't even be in the result.
Also if I remove involved_companies.company
from the included fields, it just works fine. If I remove everything but involved_companies.company
it also works. So it's probably not this. If I reduce the limit to 250 it also works.
It's really really strange.
This is the exakt code I tried it with in the video, so you can try to replicate it.
use MarcReichel\IGDBLaravel\Models\Game;
$gameIds = [41892,49,6322,178105,219115,219117,115276,68074,28663,182211,88859,222852,231822,64820,167114,225551,15421,20686,24635,159336,132044,26765,36198,14394,242025,8593,178054,90113,61573,134500,217837,159274,239007,135230,163155,223050,65974,241027,240990,11193,12427,26201,48133,178058,132842,37151,70136,78885,99959,122205,178062,8534,81275,218292,3985,248142,1066,28168,218030,75948,18011,25646,26658,68271,26223,27725,106992,225217,20687,128832,78153,87817,2336,215150,133923,135218,229339,28552,108693,10168,55190,37016,22258,51149,113114,135071,120201,198688,11668,103295,144986,208493,105049,222777,139139,218070,67024,242136,210340,14561,135148,26142,2180,3680,218883,205994,240267,248568,15690,201761,16047,16198,16203,27092,109573,153407,67940,248209,140895,159074,234545,237366,77804,14573,93517,192905,13189,55282,54678,56033,105176,109550,103314,11367,141568,54696,71443,49414,55155,8894,44897,74701,245672,11148,245299,115653,63150,20684,121025,85152,28070,41117,121504,67879,114795,26941,14676,20676,131436,159332,1887,42995,121024,77221,10740,83876,121824,13798,22962,2685,3136,229515,46067,7414,5161,5538,4033,110840,248544,111047,11,783,7433,43335,1051,141927,19164,2153,7645,198341,620,2416,351,1624,87190,229516,330,19418,3548,891,186723,181637,5038,225,959,1064,47823,660,2166,6203,5037,2482,575,869,5532,5076,2708,2946,6182,3374,215,3249,2158,96159,8264,98,4877,39342,699,87,2715,3156,136899,5338,3154,8898,135144,650,335,586,71,131,195027,4588,2113,721,4415,27075,58312,51953,5535,494,1314,90,5749,42523,1621,2656,79594,887,241008,2246,4429,159120,93789,240997,104,4905,119318,4492,192920,3350,38,2431,155199,202673,230166,36,91432,1493,1275,237,210599,1316,8224,7224,1317,96,132033,4725,35,2250,1497,4178,46226,95434,436,2588,1006,93691,934,5539,7056,759,4509,3875,5761,117772,137008,20386,67030,132029,10,1322,3145,5867,473,3094,2585,20220,14531,219121,503,78550,11675,2666,2665,3371,135243,3541,3989,132049,6964,53044,130,3901,42898,1922,3158,13115,155204,1079,1216,903,8100,4825,1494,11068,91994,904,4904,5904,2398,210703,20675,4028,103,1828,132640,5035,443,6631,4443,1059,229956,325,4506,3212,48711,2249,5971,68040,207005,950,649,51,1921,5156,3063,73027,234773,390,592,7670,5157,4258,72,22,260,214996,229521,4975,5620,205,670,5053,89,245478,2260,3752,1644,3852,4394,996,4444,3033,2500,46640,135223,229520,179730,277,7115,97,4906,5396,1002,3693,117405,41363,58941,192924,192922,231740,231741,192923,5220,3547,687,43280,7107,1832];
$igdbGames = Game::with([
'alternative_names',
'cover' => ['url', 'image_id', 'checksum'],
'platforms' => ['id'],
'genres' => ['id'],
'parent_game',
'version_parent',
'websites',
'videos',
'involved_companies',
'involved_companies.company',
'release_dates' => ['date', 'platform', 'status'],
])
->whereIn('id', $gameIds)
->take(300)
->get();
Is there an API or a way to know the latest games added to the IGDB list?
Hi,
I am trying to generate the following result for a filter in a game query:
platforms = (18) & name ~ *"final fantasy"*;
I did this:
->where('platforms', '=', '('. $request->platform . ')')->where('name', '~', '*' . $request->game . '*')
But result was:
platforms = "(18)" & name ~ "*final fantasy*"
And did not work...
Could you help me achieve this result?
Regards.
Hello I don't know whats wrong I followed every step in Readme to install and use this package but I got empty results
public function index(){
$games = Game::where('first_release_date', '>=', 1556661661000)->get();
return $games;
}
Hello,
I did not found an example for my needs.
I would like to get a total games of Playstation 2 and a list of games.
$platforms_games_total = Game::where('platforms', '28')->count();
I'm receiving Null as return.
$games = Game::where('platforms', '28')->get();
Could you help me?
Best regards.
It looks like IGDB now has something for Events on their page and I just realized that there is an endpoint that is not available with this package. https://api-docs.igdb.com/#event
I really love the way I can work with this package and would love to get events through it.
Hi there,
I use this package for a few days now to fetch some games. But the IGDB ist pretty "dirty" as I think. They have many games that aren't actual games. If I search for "Pokémon" I get something like "Pokemon: Greg Version" which is a fangame. Is there any way to filter these titles and only get "real" games? I suppose not but before I make a huge denylist for IDs I just wanted to asks if this Wrapper has something in place to help me out.
Kind Regards,
Marco
My Laravel app started to get the following error out of nowhere, even on a clean project.
HTTP request returned status code 401: { "message": "Authorization Failure. Have you tried:", "Tip 1": "Ensure you are sending Authorization and Client-I (truncated...)
I've checked with IGDB admins and I was told to check my headers and "using client_secret as oauth token is number 1 problem".
Is there a possible fix to this, I've triple-checked my keys and secrets.
Marc, I'm sorry my contribution didn't resolve the issue. I'm realizing I was testing my fork but it wasn't specifying a version number so part of the pulling process was deferring to your package during my testing. Essentially my commit is saying "no greater than 5.8" since we're on something like 5.8.3 it won't install
I think the issue is worth discussing and trying to understand further (at least for me since as I read more into it and understand composer syntax it appears having the req is it is might not be correct)
As I'm understanding the composer.json spec it appears that the laravel requirement might be better suited under require-dev. Regardless the proper way to do a 5.7 - 5.8 requirement syntactically is:
"laravel/framework": "5.7.*||5.8.*",
https://getcomposer.org/doc/articles/versions.md
Another possibility is to just do a tilde with 5.7 which would allow any release of laravel till 6
"laravel/framework": "~5.7",
Before I submit another pull request let me know if these work for you. Sorry again for making the mistake in the first place.
i am trying to use with(['cover'])
but its throw error
HTTP request returned status code 400: [ { "title": "Syntax Error", "status": 400 } ]
how can i fix it
Wondering if application compatibility includes 5.8 and if so can we get an update on the requirements to 5.7 and up?
I want to implement Webhooks but it is not clear where to place the below:
use MarcReichel\IGDBLaravel\Models\Game;
Game::createWebhook(route('handle-webhook'), 'create');
I put it in my web.php (routes file) but that resulted in the below error:
Symfony\Component\Routing\Exception\RouteNotFoundException
Route [handle-webhook] not defined.
I have tried searching on companies endpoint using the Company Model with no success. I am using the exact same code I use for searching games but I always get an empty collection.
$companies = Company::search('SEGA')->get();
Is this a bug, or am I doing something wrong?
delete it
Hi. Is there any way to explore a list of platforms that IGDB has?
I would need an example list: https://gist.github.com/ahmed-abdelazim/b533b443388baaafab3fc377e71e0109
but in json format so that I can import it more easily...
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
Hello,
after fresh install laravel 6, I get the following error:
Symfony\Component\Debug\Exception\FatalThrowableError Call to undefined function MarcReichel\IGDBLaravel\starts_with()
<?php
namespace App\Http\Controllers;
use MarcReichel\IGDBLaravel\Models\Game;
class TestController extends Controller {
function test() {
$game = Game::find(1905);
if ($game) {
echo $game->name; // Will output "Fortnite"
}
}
}
Can you please help?
Using latest version.
>>> collect($meta->platforms)->pluck('id');
=> Illuminate\Support\Collection {#5386
all: [
6,
48,
49,
130,
],
}
>>> MarcReichel\IGDBLaravel\Models\PlatformLogo::whereIn('id', [collect($meta->platforms)->pluck('id')])->get();
Illuminate\Http\Client\RequestException with message 'HTTP request returned status code 500:
{
"title": "Internal server error",
"status": 500,
"type": "https://javalin.io/documentation#internalservere (truncated...)
'
Hi there,
is there a way to count total results from a query? Using ->count()
doesn't return the total number of results.
Thanks
Hi,
Can you add more in your readme to help search names with igdb filters (lower case, '*' etc)? Like the "whereLike" solution you posted here:
#33
I was struggling with finding names with capitals and special characters for a while before i found your answer in the above link. Putting in the readme can help others
Also, if not a lot of work, can you put an example on how to make it as "Fuzzy search" as possible? e.g. Right now i split my search term by space and put each entry into multiple "orWhereLike"s. Maybe you know a more efficient way?
I create this ticket for a probable improvement. The other day I tried to create a pivot table with a polymorphic relationship, unfortunately the basic functions of the Eloquent model are not available because igdb-laravel uses a custom builder.
It would be really interesting to be able to retrieve objects directly from a polymorphic relationship.
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.
I'm on Laravel 6.20.27 running igdb-laravel 2.1.1
Plugin installs fine but when I try to publish the configuration file I get an error saying "Unable to locate publishable resources."
I have tried everything that comes to mind but I just cant get this to work. Could you please assist me?
$ php artisan vendor:publish --provider="MarcReichel\IGDB-Laravel\IGDBLaravelServiceProvider"
Unable to locate publishable resources.
Hello,
I'm trying to setup a basic Many-To-Many relationships between two models, one is "Game" from IGDBLaravel\Models and the other one is "User" from App\Models.
I set up the relationship as a property of User, like this:
use MarcReichel\IGDBLaravel\Models\Game;
public function games()
{
return $this->belongsToMany(Game::class, 'game_user', 'user_id', 'game_id');
}
I also created an intermediate table in the database, here's the migration:
public function up()
{
Schema::create('game_user', function (Blueprint $table) {
$table->foreignId('user_id');
$table->foreignId('game_id');
});
}
I populated the pivot table with a simple test row, user_id = 1 and game_id = 1905, I should get Fortnite when calling the property from User model. I try calling it in the controller like this:
$user = User::find(1);
$games = $user->games;
This should work in Many-To-Many relationship in Laravel using Eloquent, but unfortunately is not working in this case, it's returning this error:
Call to undefined method MarcReichel\IGDBLaravel\Models\Game::getConnectionName()
Am I doing something wrong?
Or is it impossible to use the wrapper like this, since they are two different kind of models?
How should I implement a relationship like this one if eloquent Models are off the table?
Many thanks in advance!
Hi (again),
Webhooks is working well. Thanks!
I would like to save successful webhook calls into the database with the name of the event, url and method. Is it possible to access more than just $event->data?
When I try to use function getUrl() I get the error message Call to a member function getUrl() on array;
use MarcReichel\IGDBLaravel\Models\Game;
$games = Game::select(["*"])->with(['cover'])->get();
return GamesResource::collection($games);
use MarcReichel\IGDBLaravel\Enums\Image\Size;
public function toArray(Request $request): array
{
return [
'cover' => $this->cover->getUrl(Size::COVER_BIG),
];
}
Doing the search by name I find it too risky to fail, just go by complex name and you are asked to break the system.
at the moment I get the game ID from the page source example:
data-react-props="{"id":1274
But is there no way to enter the url and get the game ID to get the API system started?
Firstly, thank you for the fantastic package. It is executed really well and a pleasure to use.
We are currently integrating the package, but we occasionally have an issue where the token is no longer valid. The package rightly caches the access key, however we don't know if the access key is valid until it is attempted.
To tackle this, we've implemented a workaround outside the package: catching the exception, clearing the cache key, and the package obtains a new access key upon the next request. This approach works, but integrating this functionality directly into the package could be useful.
Would you be open to considering this feature? If so, I'm happy to contribute by submitting a pull request. I wanted to discuss the idea with you before proceeding to ensure it aligns with your vision for the package.
"title": "Syntax Error",
"status": 400,
"cause": "Expecting a STRING as input, surround your input wit (truncated...)
{"userId":1,"exception":"[object] (Illuminate\Http\Client\RequestException(code: 400): HTTP request returned status code 400:
those ids:
100983
113389
163758
"title": "Internal server error",
"status": 500,
"type": "https://javalin.io/documentation#internalservere (truncated...)
{"userId":1,"exception":"[object] (Illuminate\Http\Client\RequestException(code: 500): HTTP request returned status code 500:
{
125764
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.