Skip to content

Commit 3e8802f

Browse files
committed
Handle a couple of situations where there wouldn't be an ID, like before its saved in live preview.
1 parent 3e5e1f3 commit 3e8802f

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/Entries/Entry.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ public function livePreviewUrl()
169169

170170
protected function cpUrl($route)
171171
{
172-
return cp_route($route, [$this->collectionHandle(), $this->id(), $this->slug()]);
172+
if (! $id = $this->id()) {
173+
return null;
174+
}
175+
176+
return cp_route($route, [$this->collectionHandle(), $id, $this->slug()]);
173177
}
174178

175179
public function apiUrl()
@@ -484,7 +488,11 @@ public function parent()
484488
return null;
485489
}
486490

487-
return $this->structure()->in($this->locale())->page($this->id())->parent();
491+
if (! $id = $this->id()) {
492+
return null;
493+
}
494+
495+
return $this->structure()->in($this->locale())->page($id)->parent();
488496
}
489497

490498
public function route()

0 commit comments

Comments
 (0)