PHPackages                             maize-tech/laravel-legal-consent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. maize-tech/laravel-legal-consent

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

maize-tech/laravel-legal-consent
================================

Laravel Legal Consent

3.2.0(2y ago)521.8k6[4 PRs](https://github.com/maize-tech/laravel-legal-consent/pulls)MITPHPPHP ^8.0CI passing

Since Feb 16Pushed 4mo ago6 watchersCompare

[ Source](https://github.com/maize-tech/laravel-legal-consent)[ Packagist](https://packagist.org/packages/maize-tech/laravel-legal-consent)[ Docs](https://github.com/maize-tech/laravel-legal-consent)[ GitHub Sponsors](https://github.com/maize-tech)[ RSS](/packages/maize-tech-laravel-legal-consent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (9)Versions (9)Used By (0)

   ![Social Card of Laravel Legal Consent](/art/socialcard-light.png)

Laravel Legal Consent
=====================

[](#laravel-legal-consent)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ff5a832365e36c0b98e214d9539080cca03192ee3b479eb94ffe3dbf351ac06e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61697a652d746563682f6c61726176656c2d6c6567616c2d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maize-tech/laravel-legal-consent)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8af6b8c3de05dae195d9f150353220535be2ad14c680e52f967187da5d763e59/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d61697a652d746563682f6c61726176656c2d6c6567616c2d636f6e73656e742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/maize-tech/laravel-legal-consent/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/6c0aabb4eb7f62a956d82d091a393021b7c2844997dd363fa56669adef6fcf85/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d61697a652d746563682f6c61726176656c2d6c6567616c2d636f6e73656e742f7068702d63732d66697865722e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/maize-tech/laravel-legal-consent/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/43bddd7deb56b40f381f089ce98671483c9db535597f95cca116cd09f98f1a2f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61697a652d746563682f6c61726176656c2d6c6567616c2d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maize-tech/laravel-legal-consent)

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

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require maize-tech/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"
```

This is the content of the published config file:

```
return [
    /*
    |--------------------------------------------------------------------------
    | Legal document model
    |--------------------------------------------------------------------------
    |
    | Here you may specify the fully qualified class name of the legal document model.
    |
    */

    'legal_document_model' => Maize\LegalConsent\Models\LegalDocument::class,

    /*
    |--------------------------------------------------------------------------
    | Legal consent model
    |--------------------------------------------------------------------------
    |
    | Here you may specify the fully qualified class name of the legal consent model.
    |
    */

    'legal_consent_model' => Maize\LegalConsent\Models\LegalConsent::class,

    /*
    |--------------------------------------------------------------------------
    | Legal document finder
    |--------------------------------------------------------------------------
    |
    | Here you may specify the fully qualified class name of the legal document finder class.
    |
    */

    'legal_document_finder' => Maize\LegalConsent\DefaultLegalDocumentFinder::class,

    /*
    |--------------------------------------------------------------------------
    | Route configurations
    |--------------------------------------------------------------------------
    |
    | Here you may specify whether routes should be enabled or not.
    | You can also customize the routes prefix and middlewares.
    |
    */

    'routes' => [
        'enabled' => true,
        'prefix' => 'legal',
        'name' => 'legal',
        'middleware' => ['api'],
        'endpoints' => [
            'show' => [
                'middleware' => [],
            ],
            'consent' => [
                'middleware' => ['auth:api'],
            ],
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Allowed document types
    |--------------------------------------------------------------------------
    |
    | Here you may specify the list of accepted legal document types
    | for all requests.
    |
    */

    'allowed_document_types' => [
        //
    ],

    /*
    |--------------------------------------------------------------------------
    | Allowed acceptable values
    |--------------------------------------------------------------------------
    |
    | Here you may specify the list of accepted values for each legal document
    | consent request.
    |
    */

    'allowed_acceptable_values' => [
        'yes',
        'on',
        '1',
        1,
        true,
        'true',
    ],

    /*
    |--------------------------------------------------------------------------
    | Cache
    |--------------------------------------------------------------------------
    |
    | Here you may specify the amount of time, in seconds, where each legal
    | document is cached to avoid multiple database queries.
    |
    */

    'cache' => [
        'document_ttl' => 3600,
        'document_user_ttl' => 3600,
    ],
];
```

Usage
-----

[](#usage)

### Basic

[](#basic)

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

Here's an example including the `HasLegalConsent` trait to both User and Admin models:

```
