PHPackages                             silverd/laravel-model-encryption - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. silverd/laravel-model-encryption

ActiveLibrary[Security](/categories/security)

silverd/laravel-model-encryption
================================

A trait to encrypt data models in Laravel, automatically encrypt and decrypt model data overriding getAttribute an setAttribute methods of Eloquent Model.

069↓75%PHP

Since Sep 29Pushed 7mo agoCompare

[ Source](https://github.com/silverd/laravel-model-encryption)[ Packagist](https://packagist.org/packages/silverd/laravel-model-encryption)[ RSS](/packages/silverd-laravel-model-encryption/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-model-encryption
========================

[](#laravel-model-encryption)

A trait to encrypt data models in Laravel, this automatically encrypt and decrypt model data overriding getAttribute an setAttribute methods of Eloquent Model.

How to install
--------------

[](#how-to-install)

```
composer require silverd/laravel-model-encryption:dev-master
```

Publish configuration file, this will create config/encrypt.php

```
php artisan vendor:publish --provider="Silverd\Encryptable\ServiceProvider"
```

How to use
----------

[](#how-to-use)

1. You must add `XES_ENCRYPT_CIPHER` / `XES_ENCRYPT_KEY` / `XES_ENCRYPT_IV` in your .env file or set it in your `config/encrypt.php` file
2. Use the `Silverd\Encryptable\Encryptable` trait:

```
use Silverd\Encryptable\Encryptable;
```

3. Set the `$encryptable` array on your Model.

```
protected $encryptable = ['encrypted_property'];
```

4. Here's a complete example:

```
namespace App;

use Illuminate\Database\Eloquent\Model;
use Silverd\Encryptable\Encryptable;

class User extends Model
{
    use Encryptable;

    protected $encryptable = [
        'email',
        'address' ,
        'name',
    ];
}
```

5. Optional. Encrypt your current data

If you have current data in your database you can encrypt it with the: `php artisan encryptable:encryptModel --model="App\\Models\\RxHolder"` command.

Additionally you can decrypt it using the:`php artisan encryptable:decryptModel --model="App\\Models\\RxHolder"` command.

Note: You must implement first the `Encryptable` trait and set `$encryptable` attributes

6. If you are using exists and unique rules with encrypted values replace it with exists\_encrypted and unique\_encrypted

```
$validator = validator(['email'=>'foo@bar.com'], ['email'=>'exists_encrypted:users,email']);
```

7. You can still use `where` functions

```
$validator = User::where('email','foo@bar.com')->first();
```

Automatically `foo@bar.com` will be encrypted and pass it to the query builder.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance44

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f25eb25c20073772eb82f7537265065dc3d77b2dc1cb440d658188c1dcf92c9a?d=identicon)[silverd](/maintainers/silverd)

---

Top Contributors

[![silverd](https://avatars.githubusercontent.com/u/1514608?v=4)](https://github.com/silverd "silverd (5 commits)")

### Embed Badge

![Health badge](/badges/silverd-laravel-model-encryption/health.svg)

```
[![Health](https://phpackages.com/badges/silverd-laravel-model-encryption/health.svg)](https://phpackages.com/packages/silverd-laravel-model-encryption)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[illuminate/encryption

The Illuminate Encryption package.

9229.7M280](/packages/illuminate-encryption)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
