定制 dedecube/laravel-legal-consent 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dedecube/laravel-legal-consent

Composer 安装命令:

composer require dedecube/laravel-legal-consent

包简介

Laravel Legal Consent

README 文档

README

Social Card of Laravel Legal Consent

Laravel Legal Consent

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Easily integrate legal documents (like privacy policies, terms of use, etc.) to your application.

Installation

You can install the package via composer:

composer require dedecube/laravel-legal-consent

You can publish and run the migrations with:

php artisan vendor:publish --tag="legal-consent-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="legal-consent-config"

See config file

Usage

Basic

To use the package, add the Dedecube\LegalConsent\HasLegalConsent trait to the all Authenticatable models you want to handle.

Here's an example including the HasLegalConsent trait to User :

<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Dedecube\LegalConsent\HasLegalConsent;

class User extends Authenticatable
{
    use HasLegalConsent;

    // 
}

Once done, you must define the list of allowed document types by adding them in the allowed_document_types list from config/legal-consent.php.

'allowed_document_types' => [
    'privacy-policy',
    'terms-of-use',
],

You can then create one or multiple documents from the DB or, if you wish, you could handle the creation with a CMS.

Here are the fields who should be filled:

  • type: the document type name
  • body: the content of the document
  • noted: additional notes to show for the document
  • published_at: the date of publication for the given document

Let's say we create a privacy policy document with the publication on 2021-01-01: here's the model entity we would have:

$legalDocument = [
    "id" => 1,
    "type" => "privacy-policy",
    "body" => "The privacy policy's very long text",
    "notes" => "",
    "published_at" => "2021-01-01",
    "updated_at" => "2021-01-01",
    "created_at" => "2021-01-01",
];

You can now call the custom API to retrieve and accept the current document, which can be customized in config/legal-consent.php:

GET - /legal/documents/privacy-policy

This endpoint retrieves the current legal document using the given criteria:

  • the document type must be privacy-policy
  • the published_at date must be earlier than now()

The document entries are then ordered by their published_at date in order to pick the latest one published.

The response contains the document id (used for the POST route) along with all its information useful for rendering. Here is a sample response body:

{
    "data": {
        "id": 1,
        "type": "privacy-policy",
        "body": "The privacy policy's very long text",
        "notes": "",
        "published_at": "2021-01-01"
    }
}

POST - /legal/documents/{id}

This endpoint stores the consent for the given document from the currently authenticated user.

Legal Document Listener

You can eventually accept all active legal documents using our listener.

This can be useful, for example, when your application handles the registration of users, and they must accept all legal documents through a checkbox before proceeding.

In this case, all you should do is add the listener to the Registered event in EventServiceProvider:

use Dedecube\LegalConsent\Listeners\AcceptLegalDocumentListener;

/**
 * The event listener mappings for the application.
 *
 * @var array
 */
protected $listen = [
    Registered::class => [
        AcceptLegalDocumentListener::class, // all currently active legal documents will be accepted
        SendEmailVerificationNotification::class,
    ],
];

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

dedecube/laravel-legal-consent 适用场景与选型建议

dedecube/laravel-legal-consent 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 91 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 09 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「legal」 「consent」 「Dedecube」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dedecube/laravel-legal-consent 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dedecube/laravel-legal-consent 我们能提供哪些服务?
定制开发 / 二次开发

基于 dedecube/laravel-legal-consent 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-24