Skip to content

Commit 01b187d

Browse files
Add site database table exists (#375)
* Add site database table exists * Pint * Defer to model for table * fun --------- Co-authored-by: Ryan Mitchell <[email protected]>
1 parent 65806da commit 01b187d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Sites/Sites.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
namespace Statamic\Eloquent\Sites;
44

5+
use Illuminate\Support\Facades\Schema;
56
use Statamic\Support\Str;
67

78
class Sites extends \Statamic\Sites\Sites
89
{
910
protected function getSavedSites()
1011
{
12+
$class = app('statamic.eloquent.sites.model');
13+
14+
if (! Schema::hasTable((new $class)->getTable())) {
15+
return $this->getFallbackConfig();
16+
}
17+
1118
$sites = app('statamic.eloquent.sites.model')::all();
1219

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

0 commit comments

Comments
 (0)