Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): add IconURL to API_GetConsoleIDs #2264

Merged
merged 15 commits into from
Feb 29, 2024
6 changes: 5 additions & 1 deletion app/Models/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,13 @@ public function getGamesLinkAttribute(): string

public function getIconUrlAttribute(): string
{
return asset('assets/images/system/' . Str::kebab(str_replace('/', '', Str::lower($this->name_short))) . '.png');
return asset($this->getIconUrlPath());
}

public function getIconUrlPath(): string
{
return 'assets/images/system/' . Str::kebab(str_replace('/', '', Str::lower($this->name_short))) . '.png';
}
// TODO remove after rename

public function getIdAttribute(): ?int
Expand Down
16 changes: 15 additions & 1 deletion public/API/API_GetConsoleIDs.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
* object [value]
* string ID unique identifier of the console
* string Name name of the console
* string IconURL site-relative path to the console icon
*/

return response()->json(System::select(['ID', 'Name'])->get());
$systems = System::select()->get();

$response = [];

foreach ($systems as $system) {
$data = [
'ID' => $system['ID'],
'Name' => $system['Name'],
'IconURL' => '/' . $system->getIconUrlPath(),
];
$response[] = $data;
}

return response()->json($response);
Loading