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.

072↓89.1%PHP

Since Sep 29Pushed 10mo 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 1w 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

18

—

LowBetter than 7% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

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

[phpids/phpids

PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application

791150.0k2](/packages/phpids-phpids)[paragonie/ecc

PHP Elliptic Curve Cryptography library

25866.3k44](/packages/paragonie-ecc)[nicobleiler/php-passphrase

Passphrase generator with Laravel integration, inspired by Bitwarden. Uses the EFF long word list by default with support for custom wordlists.

4912.6k](/packages/nicobleiler-php-passphrase)[dwgebler/encryption

Encryption wrapper for PHP using libsodium — simple API for symmetric and asymmetric encryption, password hashing, digital signing, and message authentication.

317.5k](/packages/dwgebler-encryption)

PHPackages © 2026

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