Download the PHP package motomedialab/compliance without Composer
On this page you can find all versions of the php package motomedialab/compliance. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download motomedialab/compliance
More information about motomedialab/compliance
Files in motomedialab/compliance
Package compliance
Short Description A package for enforcing GDPR compliance rules
License MIT
Informations about the package compliance
MotoMediaLab Compliance
MotoMediaLab compliance is a highly configurable package that helps you to stay on the right side of modern data regulations by automatically deleting records that are no longer necessary to be stored. For example, a user that hasn't logged in to your system in three years.
How does it work?
This package provides an interface and a trait that can be applied to any model. These have a series of methods that you can modify in order to change the desired functionality on a per-model basis.
By default, the package will look for a last_login_at
column on the model and
queue the record for deletion if it's older than the configured number of days
(defaults to 365 * 3 / 3 years). The last_login_at
is of course geared
towards a User
model, but the query is completely customisable per model.
Scheduled tasks
Two commands are automatically scheduled, one for checks and one for pruning.
The check command compliance:check
On a daily basis, the check job runs through all of your defined models and searches for records
that meet the deletion criteria. If the criteria is met, it'll create a ComplianceCheck
model. This will also emit a ComplianceRecordPendingDeletion
event.
This ComplianceCheck
model also stores the date on which the record should be deleted.
The prune command compliance:prune
On a daily basis, the prune job runs through all of the ComplianceCheck
records that
have exceeded the deletion_date
date. Much like the check job, it'll then once again check
for compliance. If the deletion criteria is still met, it'll delete the model and the associated
check record. Before deletion, the ComplianceDeleting
event will be emitted.
Events
The package emits two events, ComplianceRecordPendingDeletion
which is emitted when a model
is marked for deletion and ComplianceDeleting
which is emitted just before the model is deleted.
These events allow you to easily take action or notify the customer that their account will be closed without their action.
Installation
You can install the package via composer:
After installing the package, you'll need to publish the configuration file. From here, you can specify the models that should be checked for compliance. You'll also need to run the migrations.
Example
Example model:
The above implementation will use the default configuration. It'll search for all users
that have a last_login_at
column that is older than 3 years.
Configuration
The configuration file is located at config/compliance.php
. Here you can specify the models
that should be checked for compliance. You can also specify the number of days that a record
should be kept before deletion and the grace period between 'checking' and deletion.
Advanced configuration
There are a number of methods that you can override in the ComplianceRules
trait. These methods allow you
to customise the query that is run, the checks that are performed, and most importantly, an additional check
to see if a record should be deleted.