PHPackages                             ekoukltd/laraconsent - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ekoukltd/laraconsent

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ekoukltd/laraconsent
====================

User consent module for laravel

1.0.26(1y ago)07.3k↓50%1MITBlade

Since Jan 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ekoukltd/laraconsent)[ Packagist](https://packagist.org/packages/ekoukltd/laraconsent)[ Docs](https://github.com/ekoukltd/laraconsent)[ RSS](/packages/ekoukltd-laraconsent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (28)Used By (0)

LaraConsent
===========

[](#laraconsent)

This module provides versioned user consent terms and conditions which must be accepted to allow the user to continue using the application.

When a new version is published you may optionally require existing users to accept the new terms or only apply to new users.

Once a user has accepted terms on a specific version, that version is locked and may not be changed ensuring that users and the organisation will always retain a history of accepted terms.

A consent option may be applied to any user guard allowing clients and admins to require different terms. Set user models to be used in config file options. In each user model inclue the HasConsent Trait.

A consent option may also be used to signup for newsletters. Event hooks are provided which can be used to trigger subscribe / unsubscribe actions. See Events section below.

[![Add / Edit Consent Options](docs/img/ConsentIndex.png)](docs/img/ConsentIndex.png)

An index view of all accepted and declined terms is included:-

[![Add / Edit Consent Options](docs/img/ConsentsGiven.png)](docs/img/ConsentsGiven.png)

Consent editor defaults to the free summernote editor but may be switched to froala editor (licence needed) in the config file. Consent forms may be set to be published in the future and will be automatically made available on the day.

[![Add / Edit Consent Options](docs/img/ConsentEditor.png)](docs/img/ConsentEditor.png)

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

[](#installation)

Via Composer

```
composer require ekoukltd/laraconsent
```

Publish the configuration options to customise routing.

```
php artisan vendor:publish --provider="Ekoukltd\LaraConsent\LaraConsentServiceProvider" --tag="laraconsent.config"
```

For better presentation of index pages, Yarjabox Datatables is included For this to work jQuery and bootstrap must be installed:-

Typical requirements

```
 npm i jquery bootstrap@4.6.1 select2 datatables.net-bs4  datatables.net-responsive datatables.net-responsive-bs4 datatables.net-scroller-bs4
```

Or to allow printing tables to PDF, Excel or CSV, include buttons and JS PDF maker

```
 npm i jquery bootstrap@4.6.1 select2 datatables.net-bs4 datatables.net-buttons-bs4 datatables.net-responsive datatables.net-responsive-bs4 datatables.net-scroller-bs4 jszip pdfmake
```

Bootstrap 4 &amp; Bootstrap 5 templates are included

Publish views to directory /resources/views/vendor/ekoukltd &amp; /resources/views/vendor/datatables

```
php artisan vendor:publish --provider="Ekoukltd\LaraConsent\LaraConsentServiceProvider" --tag="laraconsent.views"
```

These views have been made using the Laravel 8 Breeze template format and include widgets which can be easily included into your own templates

Then publish the JS and CSS assets and translations

```
php artisan vendor:publish --provider="Ekoukltd\LaraConsent\LaraConsentServiceProvider" --tag="laraconsent.assets"
```

Check the `resources/assets/laraconsent/sass/laraconsent.scss` file and remove any css modules you may already have.

And the `resources/assets/laraconsent/js/imports.js` file and remove any already included js modules.

Update webpack.mix.js to compile our CSS

```
.sass('resources/assets/laraconsent/sass/laraconsent.scss', 'public/css')
.copy('resources/assets/laraconsent/sass/laraconsent_print.css', 'public/css')
```

Then update your resources/js/app.js to load JS assets:-

```
import Laraconsent from "../assets/laraconsent/js/laraconsent";
```

and ensure the app.js file is included in webpack.mix.js

```
.js('resources/js/app.js', 'public/js')
```

Then on the cli, compile the assets

```
npm run dev
```

Run Migrations:-

```
php artisan migrate
```

Two database tables will be created:-

- consent\_options
- consentables

consent\_options stores a versioned history of each consent form and consentables records each users consent form interaction history.

Force users to accept consent
-----------------------------

[](#force-users-to-accept-consent)

To redirect a user to accept consent page if one is outstanding, update your App\\Http\\Kernel.php 'web' middlewaregroup to include:- `\Ekoukltd\LaraConsent\Http\Middleware\ForceRedirectToUnapprovedConsents::class`

\##Authentication User routes should be available to any logged in user.

In the config\\laraconsent.php file make sure to include auth:guardname of required guards that should be able to view their consent

```
'prefix'     => 'user-consent',
'middleware' => ['web','auth:admin,web']
```

Translations
------------

[](#translations)

All phrases may be updated in the translation files:-

```
resources/lang/vendor/laraconsent/en/admin.php
resources/lang/vendor/laraconsent/en/user.php
resources/lang/vendor/laraconsent/en.json
```

Events
------

[](#events)

When an individual consent is given or denied a ConsentUpdated event is triggered. When all consents have been saved the ConsentUpdatedComplete event is triggered.

Use ConsentUpdated event to trigger an action on update of a specific consent form. Use ConsentUpdatedComplete event to trigger an action with all of the completed forms.

Customise actions in your EventServiceProvider.

These have been added by default:-

```
use Ekoukltd\LaraConsent\Events\ConsentsUpdatedComplete;
use Ekoukltd\LaraConsent\Listeners\NotifyConsentsUpdated;
use Ekoukltd\LaraConsent\Events\ConsentUpdated;
use Ekoukltd\LaraConsent\Listeners\LogConsentUpdated;

class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        //Triggered after each consent option is saved.
        ConsentUpdated::class => [
            //Add something to the log file.
            LogConsentUpdated::class,
            //Add update mailchimp subscription event here
        ],
        //Triggered after all consent options have been saved
        ConsentsUpdatedComplete::class => [
            //Sends email to user with copy of the consents
            NotifyConsentsUpdated::class
            ]
    ];
```

Usage
-----

[](#usage)

URL's may be customised in the config file.
Here you may also include your own middleware to restrict access the admin routes

```
    //Grouping of admin web routes
    'routes'     => [
        'admin' => [
            //Admin web routes should only be available to admins
            'prefix'     => 'consent-admin',
            'middleware' => ['web','auth']
        ],
        'user'  => [
            //User routes should be available to any logged in user
            'prefix'     => 'consent',
            'middleware' => ['web']
        ],
    ],
```

### Admin Routes

[](#admin-routes)

MethodURLNamed RouteGETconsent-adminconsent-admin.indexGETconsent-admin/createconsent-admin.createPOSTconsent-admin/saveconsent-admin.storeGETconsent-admin/submittedconsent-admin.submittedGETconsent-admin/{consentOption}consent-admin.showPUTconsent-admin/{consentOption}consent-admin.updateGETconsent-admin/{consentOption}/editconsent-admin.editPOSTconsent-admin/{consentOption}/toggleconsent-admin.toggle### User Routes

[](#user-routes)

MethodURLNamed RouteGETuser-consent/my-consentsuser-consent.showGETuser-consent/printuser-consent.printPOSTuser-consent/requestuser-consent.storeGETuser-consent/requestuser-consent.requestChange log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Lee Evans](https://github.com/ekoukltd)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~39 days

Recently: every ~0 days

Total

27

Last Release

559d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/133e7275d57b3053e870a66332b987ae0be489e1c61938f22196d42cf19d2be9?d=identicon)[ekoukltd](/maintainers/ekoukltd)

---

Top Contributors

[![cannycookie](https://avatars.githubusercontent.com/u/500822?v=4)](https://github.com/cannycookie "cannycookie (31 commits)")

---

Tags

consent-managementgdpr-consentlaravellaravel-packagelaravelgdpruser-consentLaraConsentISO27001

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ekoukltd-laraconsent/health.svg)

```
[![Health](https://phpackages.com/badges/ekoukltd-laraconsent/health.svg)](https://phpackages.com/packages/ekoukltd-laraconsent)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[socialiteproviders/manager

Easily add new or override built-in providers in Laravel Socialite.

42442.0M544](/packages/socialiteproviders-manager)[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5682.0M15](/packages/directorytree-ldaprecord-laravel)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.5M1](/packages/olssonm-l5-very-basic-auth)[scaler-tech/laravel-saml2

SAML2 Service Provider integration for Laravel applications, based on OneLogin toolkit

2737.5k](/packages/scaler-tech-laravel-saml2)[franbarbalopez/mirror

Mirror is a Laravel package that handles user impersonation.

1548.1k](/packages/franbarbalopez-mirror)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
