File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Whitecube \LaravelCookieConsent ;
4
+
5
+ use Illuminate \Support \ServiceProvider ;
6
+
7
+ abstract class CookiesServiceProvider extends ServiceProvider
8
+ {
9
+ /**
10
+ * Register any application services.
11
+ */
12
+ public function register ()
13
+ {
14
+ $ this ->booted (function () {
15
+ $ this ->registerCookies ();
16
+ });
17
+ }
18
+
19
+ /**
20
+ * Define the cookies users should be aware of.
21
+ */
22
+ abstract protected function registerCookies (): void ;
23
+
24
+ /**
25
+ * Bootstrap any application services.
26
+ */
27
+ public function boot ()
28
+ {
29
+ //
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Providers ;
4
+
5
+ use Whitecube \LaravelCookieConsent \Consent ;
6
+ use Whitecube \LaravelCookieConsent \Facades \Cookies ;
7
+ use Whitecube \LaravelCookieConsent \CookiesServiceProvider as ServiceProvider ;
8
+
9
+ class CookiesServiceProvider extends ServiceProvider
10
+ {
11
+ /**
12
+ * Define the cookies users should be aware of.
13
+ */
14
+ protected function registerCookies (): void
15
+ {
16
+ // Register Laravel's base cookies under the "required" cookies section:
17
+ Cookies::essentials ()
18
+ ->session ()
19
+ ->csrf ();
20
+
21
+ // Register all Analytics cookies at once using one single shorthand method:
22
+ // Cookies::analytics()
23
+ // ->google(env('GOOGLE_ANALYTICS_ID'));
24
+
25
+ // Register custom cookies under the pre-existing "optional" category:
26
+ // Cookies::optional()
27
+ // ->name('darkmode_enabled')
28
+ // ->description('This cookie helps us remember your preferences regarding the interface\'s brightness.')
29
+ // ->duration(120);
30
+ // ->accepted(fn(Consent $consent, MyDarkmode $darkmode) => $consent->cookie(value: $darkmode->getDefaultValue()));
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments