Download the PHP package dedecube/laravel-legal-consent without Composer
On this page you can find all versions of the php package dedecube/laravel-legal-consent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-legal-consent
Laravel Legal Consent
Easily integrate legal documents (like privacy policies, terms of use, etc.) to your application.
Installation
You can install the package via composer:
You can publish and run the migrations with:
You can publish the config file with:
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 :
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
.
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:
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:
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
:
Testing
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
- Daniele Tulone
- Enrico De Lazzari
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-legal-consent with dependencies
ext-json Version *
dedecube/laravel-composer Version ^0.0.2
illuminate/database Version ^9.0|^10.0|^11.0
illuminate/http Version ^9.0|^10.0|^11.0
illuminate/routing Version ^9.0|^10.0|^11.0
illuminate/support Version ^9.0|^10.0|^11.0
laravel/prompts Version ^0.1.8
spatie/laravel-package-tools Version ^1.14.1