diff --git a/app/Http/Controllers/CookieConsentController.php b/app/Http/Controllers/CookieConsentController.php new file mode 100644 index 00000000..8829eaa0 --- /dev/null +++ b/app/Http/Controllers/CookieConsentController.php @@ -0,0 +1,30 @@ +noContent()->withCookie( + $cookie->make(self::COOKIE_NAME, $request->validated("consent"), self::COOKIE_MINUTES), + ); + } + + public static function current(Request $request): string + { + $consent = $request->cookie(self::COOKIE_NAME); + + return in_array($consent, CookieConsentRequest::CONSENTS, true) ? $consent : "unknown"; + } +} diff --git a/app/Http/Requests/CookieConsentRequest.php b/app/Http/Requests/CookieConsentRequest.php new file mode 100644 index 00000000..b75772dc --- /dev/null +++ b/app/Http/Requests/CookieConsentRequest.php @@ -0,0 +1,19 @@ + ["required", "string", "in:" . implode(",", self::CONSENTS)], + ]; + } +} diff --git a/lang/en/buttons.php b/lang/en/buttons.php index 9a19637f..361aa612 100644 --- a/lang/en/buttons.php +++ b/lang/en/buttons.php @@ -19,6 +19,7 @@ "apply_now" => "Apply now!", "back_to_portfolio" => "Back to portfolio", "accept_all" => "Accept all", + "decline_all" => "Decline all", "download" => "Download", "see_how_we_can_help" => "How can we help you", "schedule_free_consultation" => "Schedule a free consultation", diff --git a/lang/en/content.php b/lang/en/content.php index 34964627..b3832520 100644 --- a/lang/en/content.php +++ b/lang/en/content.php @@ -521,7 +521,7 @@ "subtitle_3" => "or use the menu to find what you need.", ], "cookies" => [ - "text_1" => "We use cookies on our website to ensure the best possible quality of services and to adapt the website to your needs. By clicking „Accept all”, you agree to our use of cookies. To learn more, check out our", + "text_1" => "We use cookies on our website to ensure the best possible quality of services and to adapt the website to your needs. By clicking „Accept all”, you agree to our use of cookies. You can also decline them and change your choice at any time in the page footer. To learn more, check out our", "text_2" => "privacy policy.", ], "at" => "at", diff --git a/lang/en/footer.php b/lang/en/footer.php index 0e362438..820b37b2 100644 --- a/lang/en/footer.php +++ b/lang/en/footer.php @@ -6,4 +6,5 @@ "code" => "Source code", "policy" => "Privacy policy", "data" => " Company data", + "cookies" => "Cookie settings", ]; diff --git a/lang/pl/buttons.php b/lang/pl/buttons.php index 2de0aa43..6a63127d 100644 --- a/lang/pl/buttons.php +++ b/lang/pl/buttons.php @@ -19,6 +19,7 @@ "apply_now" => "Aplikuj teraz!", "back_to_portfolio" => "Wróć do portfolio", "accept_all" => "Akceptuj wszystkie", + "decline_all" => "Odrzuć wszystkie", "download" => "Pobierz", "see_how_we_can_help" => "Sprawdź, jak możemy Ci pomóc", "schedule_free_consultation" => "Umów się na bezpłatną konsultację", diff --git a/lang/pl/content.php b/lang/pl/content.php index 8d95aaab..dd563ebe 100644 --- a/lang/pl/content.php +++ b/lang/pl/content.php @@ -522,7 +522,7 @@ "subtitle_3" => "lub skorzystaj z menu, aby znaleźć to, czego potrzebujesz.", ], "cookies" => [ - "text_1" => "Na naszej stronie używamy plików cookies („ciasteczek”), aby zapewnić jak najlepszą jakość usług i dostosować stronę do Twoich potrzeb. Klikając „Akceptuj wszystkie”, wyrażasz zgodę na używanie przez nas plików cookie. Aby dowiedzieć się więcej, sprawdź naszą", + "text_1" => "Na naszej stronie używamy plików cookies („ciasteczek”), aby zapewnić jak najlepszą jakość usług i dostosować stronę do Twoich potrzeb. Klikając „Akceptuj wszystkie”, wyrażasz zgodę na używanie przez nas plików cookie. Możesz też je odrzucić, a swój wybór zmienić w każdej chwili w stopce strony. Aby dowiedzieć się więcej, sprawdź naszą", "text_2" => "politykę prywatności.", ], "at" => "w", diff --git a/lang/pl/footer.php b/lang/pl/footer.php index 6eacac5d..1c5143af 100644 --- a/lang/pl/footer.php +++ b/lang/pl/footer.php @@ -6,4 +6,5 @@ "code" => "Kod źródłowy", "policy" => "Polityka prywatności", "data" => " Dane firmy", + "cookies" => "Ustawienia cookies", ]; diff --git a/resources/views/components/cookies.blade.php b/resources/views/components/cookies.blade.php index b08f9eb3..fb3f65cc 100644 --- a/resources/views/components/cookies.blade.php +++ b/resources/views/components/cookies.blade.php @@ -1,22 +1,80 @@ +@php + $cookieConsent = \Blumilk\Website\Http\Controllers\CookieConsentController::current(request()); +@endphp + -
-
- +
diff --git a/resources/views/layout/public.blade.php b/resources/views/layout/public.blade.php index dda933ad..9d59eedd 100644 --- a/resources/views/layout/public.blade.php +++ b/resources/views/layout/public.blade.php @@ -24,11 +24,13 @@ - + @if (\Blumilk\Website\Http\Controllers\CookieConsentController::current(request()) !== "declined") + + @endif {!! RecaptchaV3::initJs() !!} diff --git a/routes/web.php b/routes/web.php index c87b6576..5df04fc4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,6 +6,7 @@ use Blumilk\Website\Http\Controllers\CareerController; use Blumilk\Website\Http\Controllers\CompanyDataController; use Blumilk\Website\Http\Controllers\ContactController; +use Blumilk\Website\Http\Controllers\CookieConsentController; use Blumilk\Website\Http\Controllers\HomeController; use Blumilk\Website\Http\Controllers\LogoController; use Blumilk\Website\Http\Controllers\NewsController; @@ -38,4 +39,6 @@ $router->get($uri->translate("offer"), OfferController::class)->name("offer"); +$router->post("cookie-consent", CookieConsentController::class)->name("cookie-consent"); + $router->fallback(FallbackController::class);