Skip to content

Commit 5f2c8ca

Browse files
committed
guardrail for null activeFrom
1 parent fbf9d3f commit 5f2c8ca

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

app/Http/Resources/PolicyResource.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ class PolicyResource extends JsonResource {
1515
public static $wrap = null;
1616

1717
public function toArray(Request $request): array {
18+
$activeFrom = $this->active_from;
19+
20+
if ($this->active_from !== null) {
21+
$activeFrom = Carbon::parse($this->active_from)->format('Y-m-d');
22+
}
23+
1824
return [
1925
'metadata' => [
2026
'policy_id' => $this->id,
2127
'type' => $this->policy_type,
22-
'active_from' => Carbon::parse($this->active_from)->format('Y-m-d'),
28+
'active_from' => $activeFrom,
2329
'content_vue_file' => $this->content_vue_file,
2430
],
2531
];

0 commit comments

Comments
 (0)