1 - Add this package
https://github.com/spatie/laravel-cookie-consent
2 - publish the package to get the custom configuration
php artisan vendor:publish
3 - Add this in the home page in the top
@include('cookieConsent::index')
4 - Add the below style in the file “resources/views/vendor/cookieConsent/dialogContents.blade.php”
<div class="js-cookie-consent cookie-consent">
<div class="alert alert-warning alert-dismissible fade show text-center" role="alert" style="margin-bottom: 0rem !important;">
<span class="cookie-consent__message">
{!! trans('cookieConsent::texts.message') !!}
</span>
<button class="js-cookie-consent-agree cookie-consent__agree btn btn-sm btn-primary">
{{ trans('cookieConsent::texts.agree') }}
</button>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
</div>
Sources
- https://github.com/spatie/laravel-cookie-consent
- https://stackoverflow.com/questions/60719259/unable-to-locate-publishable-resources