From 283c8d16b514da85f6b466d8d15df52183fe72c4 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 5 Apr 2024 20:00:44 -0400 Subject: [PATCH 1/2] Adding anonymous blade components from theme folder --- src/ThemesServiceProvider.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ThemesServiceProvider.php b/src/ThemesServiceProvider.php index c11a7ae..f338a50 100644 --- a/src/ThemesServiceProvider.php +++ b/src/ThemesServiceProvider.php @@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Blade; class ThemesServiceProvider extends ServiceProvider { @@ -84,6 +85,7 @@ public function boot() $this->themes_folder = config('themes.themes_folder', resource_path('views/themes')); $this->loadDynamicMiddleware($this->themes_folder, $theme); + $this->registerThemeComponents($theme); // Make sure we have an active theme if (isset($theme)) { @@ -114,6 +116,10 @@ public function addThemeRoutes($router) $router->delete('themes/delete', ['uses' => $namespacePrefix.'ThemesController@delete', 'as' => 'theme.delete']); } + private function registerThemeComponents($theme){ + Blade::anonymousComponentPath(resource_path('views/themes/anchor/components')); + } + /** * Adds the Theme icon to the admin menu. * From 7fdb0a59351f8ae837ccc3c497065ad28f0f16d4 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Wed, 10 Apr 2024 09:56:28 -0400 Subject: [PATCH 2/2] Adding functionality to support pages --- src/ThemesServiceProvider.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ThemesServiceProvider.php b/src/ThemesServiceProvider.php index f338a50..4252d85 100644 --- a/src/ThemesServiceProvider.php +++ b/src/ThemesServiceProvider.php @@ -15,6 +15,8 @@ use Illuminate\Support\ServiceProvider; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Blade; +use Laravel\Folio\Folio; +use Illuminate\Support\Facades\File; class ThemesServiceProvider extends ServiceProvider { @@ -86,6 +88,7 @@ public function boot() $this->loadDynamicMiddleware($this->themes_folder, $theme); $this->registerThemeComponents($theme); + $this->registerThemeFolioDirectory($theme); // Make sure we have an active theme if (isset($theme)) { @@ -117,7 +120,18 @@ public function addThemeRoutes($router) } private function registerThemeComponents($theme){ - Blade::anonymousComponentPath(resource_path('views/themes/anchor/components')); + Blade::anonymousComponentPath(resource_path('views/themes/' . $theme->folder . '/components/elements')); + Blade::anonymousComponentPath(resource_path('views/themes/' . $theme->folder . '/components')); + } + + private function registerThemeFolioDirectory($theme){ + if (File::exists(resource_path('views/themes/' . $theme->folder . '/pages'))) { + Folio::path(resource_path('views/themes/' . $theme->folder . '/pages'))->middleware([ + '*' => [ + // + ], + ]); + } } /**