Skip to content

Commit 7cf809a

Browse files
authored
Conditionally query against order column in Sites.php (#473)
* Conditionally query against order column in Sites.php * Linting
1 parent 8f4d2f9 commit 7cf809a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Sites/Sites.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ class Sites extends \Statamic\Sites\Sites
1010
protected function getSavedSites()
1111
{
1212
$class = app('statamic.eloquent.sites.model');
13+
$table = (new $class)->getTable();
1314

14-
if (! Schema::hasTable((new $class)->getTable())) {
15+
if (! Schema::hasTable($table)) {
1516
return $this->getFallbackConfig();
1617
}
1718

18-
$sites = app('statamic.eloquent.sites.model')::query()->orderBy('order')->get();
19+
$sites = app('statamic.eloquent.sites.model')::query()
20+
->when(Schema::hasColumn($table, 'order'), fn ($query) => $query->orderBy('order'))
21+
->get();
1922

2023
return $sites->isEmpty() ? $this->getFallbackConfig() : $sites->mapWithKeys(function ($model) {
2124
return [

0 commit comments

Comments
 (0)