-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from whitecube/feature-service-provider
Feature service provider
- Loading branch information
Showing
4 changed files
with
109 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Whitecube\LaravelCookieConsent; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
abstract class CookiesServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register any application services. | ||
*/ | ||
public function register() | ||
{ | ||
$this->booted(function () { | ||
$this->registerCookies(); | ||
}); | ||
} | ||
|
||
/** | ||
* Define the cookies users should be aware of. | ||
*/ | ||
abstract protected function registerCookies(): void; | ||
|
||
/** | ||
* Bootstrap any application services. | ||
*/ | ||
public function boot() | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use Whitecube\LaravelCookieConsent\Consent; | ||
use Whitecube\LaravelCookieConsent\Facades\Cookies; | ||
use Whitecube\LaravelCookieConsent\CookiesServiceProvider as ServiceProvider; | ||
|
||
class CookiesServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Define the cookies users should be aware of. | ||
*/ | ||
protected function registerCookies(): void | ||
{ | ||
// Register Laravel's base cookies under the "required" cookies section: | ||
Cookies::essentials() | ||
->session() | ||
->csrf(); | ||
|
||
// Register all Analytics cookies at once using one single shorthand method: | ||
// Cookies::analytics() | ||
// ->google(env('GOOGLE_ANALYTICS_ID')); | ||
|
||
// Register custom cookies under the pre-existing "optional" category: | ||
// Cookies::optional() | ||
// ->name('darkmode_enabled') | ||
// ->description('This cookie helps us remember your preferences regarding the interface\'s brightness.') | ||
// ->duration(120); | ||
// ->accepted(fn(Consent $consent, MyDarkmode $darkmode) => $consent->cookie(value: $darkmode->getDefaultValue())); | ||
} | ||
} |