by betterapp

255 Stars 17 Forks Last release: about 1 month ago (v1.0.1) MIT License 28 Commits 2 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Laravel Db Encrypter Package

This package was created to encrypt and decrypt values of Eloquent model attributes.


If You think this package helped You, please donate. Thank You.

Key features

  • Encrypt, decrypt values stored in database fields
  • Using standard Laravel's Crypt service
  • Easy configuration


  • Laravel: 6.0 and up
  • PHP: 7.1 and newer

Database schema

Encrypted values are stored as plain text so in most cases takes up more spaces then unencrypted one. Recommendation is to alter table column to

type. If you want use
column type still you need to check if encrypted value fit.


Do not worry if you have current data in your database not encrypted and added column to

- they will return as is.
On save values will be encrypted and everything will work fine.


Via Composer command line:

$ composer require betterapp/laravel-db-encrypter


  1. Use the
    trait in any Eloquent model that you wish to use encryption
  2. Define a
    protected $encryptable
    array containing a list of the encrypted attributes.

For example:

    use betterapp\LaravelDbEncrypter\Traits\EncryptableDbAttribute;

class Client extends Eloquent {
    use EncryptableDbAttribute;

    /** @var array The attributes that should be encrypted/decrypted */
    protected $encryptable = [

  1. You can use Laravel's original $casts to cast decrypted values


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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.