Skip to content

Commit

Permalink
Don't explode on nonexisting country acronym
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Sep 26, 2024
1 parent 13eae0c commit 1f9bbfd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/Transformers/UserCompactTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ public function includeCommentsCount(User $user)

public function includeCountry(User $user)
{
return $this->item(app('countries')->byCode($user->country_acronym), new CountryTransformer());
$country = app('countries')->byCode($user->country_acronym);

return $country === null
? $this->primitive(null)
: $this->item($country, new CountryTransformer());
}

public function includeCover(User $user)
Expand Down

0 comments on commit 1f9bbfd

Please sign in to comment.