Skip to content

tjgazel/laravel-accept-cookies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pop-up cookie acceptance terms for Laravel 5.5+, 6, 7, 8

Latest Stable Version License Total Downloads




See examples in:
https://alfaunipac.com.br
https://unipacto.com.br
https://faculdadealfa.com.br

installation and configuration

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.



Tanks for:

Bootstrap
JQuery
Laravel

Author: Talles Gazel
Linkedin

About

Pop-up cookie acceptance terms for Laravel 5.5+

Resources

License

Stars

Watchers

Forks

Packages

No packages published