Skip to content

Commit

Permalink
better?
Browse files Browse the repository at this point in the history
  • Loading branch information
edalzell committed Dec 2, 2024
1 parent 8ae4bf6 commit 32e8b02
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Entries/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,16 @@ public function collection($collection = null)
}

$this->computedCallbackCache = null;
$this->collection = $collection instanceof \Statamic\Contracts\Entries\Collection ? $collection->handle() : $collection;

if (is_null($customClass = Collection::findByHandle($this->collection)->class())) {
if ($collection instanceof \Statamic\Contracts\Entries\Collection) {
$this->collection = $collection->handle();
$customClass = $collection->class();
} else {
$this->collection = $collection;
$customClass = Collection::findByHandle($this->collection)->class();
}

if (is_null($customClass)) {
return $this;
}

Expand Down

0 comments on commit 32e8b02

Please sign in to comment.