Closed PiousVenom closed 3 years ago
null
is returned whenever a result could not be found. In your case the company could not be found because the 95000
refers to an InvolvedCompany
which is different to a normal Company
. The InvolvedCompany
has a company
which holds the regular Company
you are looking for (14486
in your case).
You can simplify your API call by expending your request like so:
$game = Game::with(['involved_companies', 'involved_companies.company'])->find(1905); // Fortnite in this example
dd($game->involved_companies->first()->company->name); // returns "People Can Fly"
This way you have only one API call and do not need to query the API again with the ID of the InvolvedCompany
and then query the API again with the ID of the Company
you got from the previous API call.
That... makes some sense. Looking at the return attributes of involved_companies
, I thought that was the company itself. Thanks for the help.
Glad to help 😊
I'm trying to run the following:
$company = Company::find(95000);
. I got the 95000 from a game query in theinvolved_companies
. Are somecompany
returns reallynull
?