From ae9a8fcd62ecb682a7562e970f2c05e8517ea4af Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 27 Feb 2020 19:17:30 +0100 Subject: [PATCH] wip #3439 @0.5 --- src/app/Magic/Menu/Item.php | 12 ++++++++++-- src/app/Template/TemplateAbstract.php | 3 +++ src/resources/install/app/Models/Page.php | 10 ++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/resources/install/app/Models/Page.php diff --git a/src/app/Magic/Menu/Item.php b/src/app/Magic/Menu/Item.php index 69ccc8b..03cd567 100644 --- a/src/app/Magic/Menu/Item.php +++ b/src/app/Magic/Menu/Item.php @@ -9,6 +9,8 @@ use Cubist\Backpack\app\Magic\Models\Locale; use Cubist\Backpack\app\Magic\PageData; use Cubist\Backpack\app\Template\Navigation; use Cubist\Backpack\Facades\App; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\QueryException; use Illuminate\Support\Str; class Item @@ -127,13 +129,19 @@ class Item $class = CMSPage::getPageClass(); /** @var $all CMSPage[] */ /** @var Eloquent $r */ - $all = $class::whereVariant($this->getVariant())->orderBy('lft')->get(); + try { + $all = $class::whereVariant($this->getVariant())->orderBy('lft')->get(); + } catch (QueryException $e) { + $all = null; + } $this->setId('#root'); $this->setRoot($this); $this->setBreadcrumbs(false); $this->setName($id); - $this->setChildrenFromData($all, null); + if (null !== $all) { + $this->setChildrenFromData($all, null); + } } /** diff --git a/src/app/Template/TemplateAbstract.php b/src/app/Template/TemplateAbstract.php index 21dc7d0..fe2af61 100644 --- a/src/app/Template/TemplateAbstract.php +++ b/src/app/Template/TemplateAbstract.php @@ -97,6 +97,9 @@ class TemplateAbstract self::$_templates = []; $roots = [__DIR__ => 'Cubist\\Backpack\\app\\Template', app_path() . '/Templates' => 'App\\Templates']; foreach ($roots as $templates_root => $prefix) { + if (!file_exists($templates_root)) { + continue; + } $dr = opendir($templates_root); while ($file = readdir($dr)) { if ($file == '.' || $file == '..' || is_dir($templates_root . '/' . $file)) { diff --git a/src/resources/install/app/Models/Page.php b/src/resources/install/app/Models/Page.php new file mode 100644 index 0000000..f2fc9bb --- /dev/null +++ b/src/resources/install/app/Models/Page.php @@ -0,0 +1,10 @@ +