Skip to content

Commit

Permalink
More null check
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Sep 26, 2024
1 parent 1f9bbfd commit ef5d91e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/Transformers/UserCompactTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ public function includeCommentsCount(User $user)

public function includeCountry(User $user)
{
$country = app('countries')->byCode($user->country_acronym);
$countryAcronym = $user->country_acronym;
$country = $countryAcronym === null
? null
: app('countries')->byCode($countryAcronym);

return $country === null
? $this->primitive(null)
Expand Down

0 comments on commit ef5d91e

Please sign in to comment.