taylornetwork / model-encryption
Adds encryption to Laravel models using Laravel's built in encryption
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/taylornetwork/model-encryption
Requires
- php: >=5.4.0
- laravel/framework: 5.3.*
This package is auto-updated.
Last update: 2025-10-24 14:19:15 UTC
README
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
- Main Author: Sam Taylor
License
The MIT License (MIT). Please see License File for more information.