Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Trait for use with Laravel 5 models allowing easy encryption of values.

License

Notifications You must be signed in to change notification settings

engageinteractive/Encryptable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Encryptable

A trait for use with Laravel 5 models allowing easy encryption/decryption of attributes.

Installation

Add the following to the composer.json file in your project:

"engage/encryptable": "1.*"

or you can run the below on the command line in the root of your project:

composer require "engage/encryptable" "1.*"

Ensure you are using the Engage composer repository in your composer.json

"repositories": [
    {
        "type": "composer",
        "url": "http://composer.engageinteractive.co.uk"
    }
],

"config": {
    "secure-http": false
}

Setup

To get started, add the trait to the model.

You also need to add an array detailing which attributes should be encrypted. Add this as a property on your model called $encryptedAttributes.

use Engage\Encryptable\Encryptable;

class YourModel extends Eloquent
{
    use Encryptable;

    protected $encryptedAttributes = [
        'first_name',
        'surname',
        'email_address'
    ];

Notes

As this uses the encryption that ships with Laravel, please ensure you have set an app key before using this, otherwise your encrypted attributes will not be secure. Additionally, do not lose your app key, or you will not be able to decrypt your attributes.

Any issues decrypting attributes will be added to the Laravel log file, so if things aren't working as expected then check here first for details about the problem.

About

Trait for use with Laravel 5 models allowing easy encryption of values.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages