dtisgodsson/elocrypt

There is no license information available for the latest version (v1.6) of this package.

Automatically encrypt and decrypt Eloquent attributes with ease.

v1.6 2016-04-15 11:17 UTC

This package is not auto-updated.

Last update: 2024-04-09 01:42:48 UTC


README

Installation

This package can be installed via Composer by adding the following to your composer.json file:

"require": {
	"dtisgodsson/elocrypt": "1.*"
}

You must then run the following command:

composer update

Usage

Simply reference the ElocryptTrait in any Eloquent Model you wish to apply encryption to and then define an "encryptable" array on that model containing a list of the attributes you wish to Encrypt.

For example:

class User extends Eloquent {

		use ElocryptTrait;

		public $encryptable = ['first_name', 'last_name', 'address_line_1', 'postcode'];
}

How it Works?

By including the ElocryptTrait, the __set() and __get() methods provided by Eloquent are overridden to include an additional step. This additional step simply checks whether the attribute being set or get is included in the "encryptable" array on the model, and either encrypts/decrypts it accordingly OR calls the parent __set() or __get() method.