Skip to content

Commit b354e67

Browse files
committed
refactor: change the returned value of phone number in UserResource
1 parent b5da09c commit b354e67

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

app/Http/Resources/UserResource.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function toArray(Request $request): array
2020
'name' => $this->name,
2121
'last_name' => $this->last_name,
2222
'email' => $this->email,
23-
'phone_number' => $this->formatPhoneNumber(),
23+
'phone_number' => $this->phone_number,
2424
'phone_country' => $this->phone_country,
2525
'voivodship' => $this->voivodship,
2626
'city' => $this->city,
@@ -32,18 +32,4 @@ public function toArray(Request $request): array
3232
'updated_at' => $this->updated_at,
3333
];
3434
}
35-
36-
private function formatPhoneNumber(): ?string
37-
{
38-
if (empty($this->phone_number)) {
39-
return null;
40-
}
41-
try {
42-
$phone = new PhoneNumber($this->phone_number, $this->phone_country);
43-
44-
return $phone->formatNational();
45-
} catch (\Throwable $e) {
46-
return $this->phone_number;
47-
}
48-
}
4935
}

0 commit comments

Comments
 (0)