承接 senses/laravel-gdpr 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

senses/laravel-gdpr

Composer 安装命令:

composer require senses/laravel-gdpr

包简介

Laravel package for under the hood management of GDPR permission cookies.

README 文档

README

Laravel package to handle management of cookies via type. Heavily inspired by Spatie's laravel-cookie-consent package

Installation

composer require senses/laravel-gdpr

In config/app.php

// Add to service providers array
Senses\Gdpr\GdprServiceProvider::class,

// Add to aliases array
'Gdpr' => Senses\Gdpr\GdprFacade::class,

Usage

Backend

In your layout file, include the @gdprjs directive somewhere inside your <body> tag.

You can then use the directive @gdpr('category') which acts as an if statement based on whether or not the user has accepted the cookie.

You can publish the package's config to config/gdpr.php with php artisan vendor:publish.

php artisan vendor:publish --provider="Senses\Gdpr\GdprServiceProvider"

The default categories for cookies are:

'types' => [
    'necessary', 'functional', 'analytics', 'settings'
]

You can change this in your published config, along with the cookie name and lifetime.

You can disable the plugin by setting GDPR_ENABLED to false in your .env. file.

Frontend

Provided the @gdprjs directive is present, you can manipulate the gdpr settings via javascript.

The package binds a laravelGdpr object to the window object. Allowing you to work with the package from there.

It's best to reload the page once you're done changing these settings in order for the user's configuration to come into effect.

The laravelGdpr object has two methods inside it:

laravelGdpr.get() will return the user's entire config.

laravelGdpr.set(category, value) accepts two parameters, category and value. value should be boolean.

The package is frontend-agnostic, allowing you to use your own CSS and JS to construct the GDPR permissions modal.

When one of your toggles or checkboxes is changed, you will need to call the laravelGdpr.set() method.

Quick Example:

document.querySelector('input[type="checkbox"]#third_party').addEventListener('click', function(e) {
    laravelGdpr.set('third_party', e.target.checked);
});

There is a full example Vue component available on codesandbox

统计信息

  • 总下载量: 92
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固