PHPackages                             hihaho/laravel-encryptable-trait - 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. [Database &amp; ORM](/categories/database)
4. /
5. hihaho/laravel-encryptable-trait

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

hihaho/laravel-encryptable-trait
================================

Laravel encryptable trait, easily make certain fields for eloquent models encryptable

v4.0.0(2y ago)1064.3k↓50%3MITPHPPHP ^8.1

Since Sep 12Pushed 1y ago2 watchersCompare

[ Source](https://github.com/hihaho/laravel-encryptable-trait)[ Packagist](https://packagist.org/packages/hihaho/laravel-encryptable-trait)[ Docs](https://github.com/hihaho/laravel-encryptable-trait)[ RSS](/packages/hihaho-laravel-encryptable-trait/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (11)Used By (0)

Laravel Encryptable Trait
=========================

[](#laravel-encryptable-trait)

[![License](https://camo.githubusercontent.com/a250b1de6211e3e1944db4eb8c5f6954370f28239dcbe35805959dfdaa06f170/68747470733a2f2f706f7365722e707567782e6f72672f68696861686f2f6c61726176656c2d656e637279707461626c652d74726169742f6c6963656e7365)](https://packagist.org/packages/hihaho/laravel-encryptable-trait)

Warning

No longer maintained
====================

[](#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

[](#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

[](#install)

Simply add the following line to your `composer.json` and run `composer update`

```
"hihaho/laravel-encryptable-trait": "^v4.0"

```

Or use composer to add it with the following command

```
composer require hihaho/laravel-encryptable-trait
```

#### Requirements

[](#requirements)

- illuminate/encryption ^10.0 or ^11.0
- PHP 8.1, 8.2 or 8.3

### Usage

[](#usage)

Simply add the trait to your models and set the `$encryptable` to an array of values that need to be encrypted.

```
