taylornetwork / model-encryption by samueljtaylor

Adds encryption to Laravel models using Laravel's built in encryption
12
1
2
Package Data
Maintainer Username: samueljtaylor
Maintainer Contact: sam@taylornetwork.ca (Sam Taylor)
Package Create Date: 2016-11-16
Package Last Update: 2016-11-16
Language: PHP
License: Unknown
Last Refreshed: 2025-02-09 15:02:04
Package Statistics
Total Downloads: 12
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Model Encryption Trait

This is a trait for Laravel that overrides the default getter and setters to encrypt and decrypt the values using Laravel's builtin encrypt and decrypt functions.

Install

Via Composer

$ composer require taylornetwork/model-encryption

Usage

Include Encryptable trait in any model you want to add encryption and add a $encryptable property with an array of attributes to encrypt/decrypt.


use TaylorNetwork\ModelEncryption\Encryptable;

class DummyModel extends Model
{
    use Encryptable;

    /**
     * Model attributes to encrypt/decrypt
     *
     * @var array
     */
    protected $encryptable = [
        'dummy_attribute'
    ];

    // Code

}

When accessing any property, the Encryptable trait will determine if the attribute is in the $encryptable array, if so, encrypt/decrypt. Otherwise get/set as normal.

Credits

License

The MIT License (MIT). Please see License File for more information.