Skip to content

Commit e1c64f5

Browse files
authored
Use the correct site from Statamic (#174)
1 parent b81d49e commit e1c64f5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Models/Traits/HasContentEntry.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Eloquent\Casts\Attribute;
66
use Statamic\Facades\Entry;
77
use Statamic\Facades\Site;
8+
use Statamic\Statamic;
89

910
trait HasContentEntry
1011
{
@@ -14,7 +15,7 @@ protected function entry(): Attribute
1415
return Attribute::make(
1516
get: fn() => Entry::query()
1617
->where('collection', $this->collection)
17-
->where('site', Site::selected()->handle())
18+
->where('site', Statamic::isCpRoute() ? Site::selected()->handle() : Site::current()->handle())
1819
->where($this->linkField, $this?->{$this->getKeyName()} ?? null)
1920
->first(),
2021
)->shouldCache();

0 commit comments

Comments
 (0)