- Dependencies
- Boostrap 4
- JQuery 3
- installation and configuration
- Tanks
See examples in:
https://alfaunipac.com.br
https://unipacto.com.br
https://faculdadealfa.com.br
1) Run composer require tjgazel/laravel-accept-cookies
to include this in your project. Will automatically
discover the provider and the alias.
2) Run php artisan vendor:publish --provider="TJGazel\Laravel\AcceptCookies\AcceptCookiesProvider" --tag="accept-cookies:config"
to publish the config file in config/accept-cookies.php
.
<?php
return [
'sessionName' => 'accept-cookies',
'route' => [
'middleware' => [],
'prefix' => 'accept-cookies',
'name' => 'accept-cookies.',
'route' => [
'name' => 'accept',
'url' => '/accept'
]
],
'background-color' => 'bg-dark',
'text' => 'We use cookies and similar technologies to offer you a better experience on our platform, improve performance, analyze your interactions on our site and personalize content. To learn more, see our Privacy Policy.',
'linkMoreInfoUrl' => 'https://my-site.com/storage/more-info.pdf',
'linkMoreInfoTarget' => '_blank',
'linkMoreInfoText' => 'More info.',
'linkMoreInfoCollor' => 'text-primary',
'btnAcceptText' => 'Accept',
'btnAcceptColor' => 'text-success',
'btnRefuseText' => 'Refuse',
'btnRefuseColor' => 'text-danger',
];
3) Include AcceptCookies::routes()
in routes/web.php
.
<?php
AcceptCookies::routes();
Route::get('/', function() {
//
});
4) 1 - Include <meta name="csrf-token" content="{{ csrf_token() }}">
.
2 - Include @stack('js')
after jquery and boostrap scripts.
3 - Include@include('accept-cookies::template')
somewhere in your template.
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="stylesheet" type="text/css" href="/css/app.css">
</head>
<body>
<div id="app">
<header></header>
<main>
@yield('content')
</main>
<footer></footer>
@include('accept-cookies::template')
</app>
<script type="text/javascript" src="js/app.js"></script>
@stack('js')
</body>
</html>
5) Optional:
Run php artisan vendor:publish --provider="TJGazel\Laravel\AcceptCookies\AcceptCookiesProvider" --tag="accept-cookies:views"
to publish the template view. Modify the published template located
at resources/views/vendor/accept-cookies/template.php
to your liking.
Author: Talles Gazel
Linkedin