From 177aa24b7bfb483c1e769b9749caa13331b2b025 Mon Sep 17 00:00:00 2001 From: Kamil Date: Fri, 30 Aug 2024 14:25:15 +0200 Subject: [PATCH] #30 - wip: added some stuff connected with configuring sections via config --- .env.example | 4 ++ app/Http/Middleware/HandleInertiaRequests.php | 10 +++ app/Policies/UserPolicy.php | 25 ++++++++ config/keating.php | 11 ++++ resources/js/Layouts/PublicLayout.vue | 63 ++++++++++++------- routes/web.php | 3 +- 6 files changed, 91 insertions(+), 25 deletions(-) create mode 100644 app/Policies/UserPolicy.php create mode 100644 config/keating.php diff --git a/.env.example b/.env.example index 0e7f275..03dde5c 100644 --- a/.env.example +++ b/.env.example @@ -20,3 +20,7 @@ DOCKER_DATABASE_HOST_PORT=53853 DOCKER_REDIS_HOST_PORT=53852 DOCKER_INSTALL_XDEBUG=true DOCKER_HOST_USER_ID=1000 + +CONTACT_ENABLED=true +FAQ_ENABLED=true +NEWS_ENABLED=true diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index a3640bf..e09b3fb 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -15,6 +15,7 @@ public function share(Request $request): array return array_merge(parent::share($request), [ "auth" => $this->getAuthData($request), "flash" => $this->getFlashData($request), + "sections" => $this->getSectionsData(), ]); } @@ -33,4 +34,13 @@ protected function getFlashData(Request $request): Closure "info" => $request->session()->get("info"), ]; } + + protected function getSectionsData(): array + { + return [ + "faq_enabled" => config("keating.sections.faq_enabled"), + "contact_enabled" => config("keating.sections.contact_enabled"), + "news_enabled" => config("keating.sections.news_enabled"), + ]; + } } diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php new file mode 100644 index 0000000..dd3508f --- /dev/null +++ b/app/Policies/UserPolicy.php @@ -0,0 +1,25 @@ + [ + "faq_enabled" => env("FAQ_ENABLED", true), + "contact_enabled" => env("CONTACT_ENABLED", true), + "news_enabled" => env("ABOUT_ENABLED", true), + ], +]; diff --git a/resources/js/Layouts/PublicLayout.vue b/resources/js/Layouts/PublicLayout.vue index 82a8b34..d5e3910 100644 --- a/resources/js/Layouts/PublicLayout.vue +++ b/resources/js/Layouts/PublicLayout.vue @@ -1,16 +1,17 @@