Download the PHP package hihaho/laravel-encryptable-trait without Composer
On this page you can find all versions of the php package hihaho/laravel-encryptable-trait. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hihaho/laravel-encryptable-trait
More information about hihaho/laravel-encryptable-trait
Files in hihaho/laravel-encryptable-trait
Package laravel-encryptable-trait
Short Description Laravel encryptable trait, easily make certain fields for eloquent models encryptable
License MIT
Homepage https://github.com/hihaho/laravel-encryptable-trait
Informations about the package laravel-encryptable-trait
Laravel Encryptable Trait
[!WARNING]
No longer maintained
We no longer use this package and will not maintain it. Please feel free to fork it and maintain it yourself.
Consider migrating to Laravel encryption features which we added since this package was created.
This package uses serialized encryption, while the Laravel encryption casts unserialized encryption. You can upgrade uses of this package to custom casts, e.g. by implementing
Illuminate\Contracts\Database\Eloquent\Castable
on a data object used as cast.
Introduction
This trait encrypts all your fields (defined in $this->encryptable
) before saving it to the database.
It makes it extremely easy to treat certain fields as encryptable by automatically encrypting and decrypting the values.
Install
Simply add the following line to your and run
Or use composer to add it with the following command
Requirements
- illuminate/encryption ^10.0 or ^11.0
- PHP 8.1, 8.2 or 8.3
Usage
Simply add the trait to your models and set the to an array of values that need to be encrypted.
DecryptException
This package will throw a DecryptException (the default Laravel one: ). You can however set to true to ignore the exception. If the value can't be decrypted it will just return null.
If the database contains an invalid value, this will return null.
``