PHPackages                             sagalbot/encryptable - 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. sagalbot/encryptable

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

sagalbot/encryptable
====================

Allows you to store Eloquent properties encrypted in your database, and automatically decrypt when accessed.

v1.0.1(6y ago)2757.0k↑890%2[3 issues](https://github.com/sagalbot/encryptable/issues)2MITPHPPHP &gt;=5.6.4CI failing

Since Apr 19Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sagalbot/encryptable)[ Packagist](https://packagist.org/packages/sagalbot/encryptable)[ RSS](/packages/sagalbot-encryptable/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (2)

Encryptable Eloquent Model Properties [![Build Status](https://camo.githubusercontent.com/d5ffbf611ab361b9641f8e8221ab7226d81fed170c3a3677dfca9e86aa8886f9/68747470733a2f2f7472617669732d63692e6f72672f736167616c626f742f656e637279707461626c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sagalbot/encryptable)
=================================================================================================================================================================================================================================================================================================================================

[](#encryptable-eloquent-model-properties-)

> A Laravel 5 package that allows you to store Eloquent model properties encrypted in your database, and automatically decrypts them when you need to access them.

[![example](https://cloud.githubusercontent.com/assets/692538/25161465/f7c82b6e-2470-11e7-8b41-f23c09115e7d.png)](https://cloud.githubusercontent.com/assets/692538/25161465/f7c82b6e-2470-11e7-8b41-f23c09115e7d.png)

Install
-------

[](#install)

```
composer require sagalbot/encryptable
```

Usage
-----

[](#usage)

This package is really just a simple trait and property that you can add to your Eloquent models. Usage is simple:

1. Before using Laravel's encrypter, you must set a key option in your config/app.php configuration file.

    ```
    artisan key:generate
    ```

    **note:** *If you already have `APP_KEY` set in your `.env`, you should skip this step.*
2. Use the `Sagalbot\Encryptable\Encryptable` trait:

    ```
    use \Sagalbot\Encryptable\Encryptable;
    ```
3. Set the `$encryptable` array on your Model.

    ```
    protected $encryptable = ['my_encrypted_property'];
    ```
4. That's it! Here's a complete example:

    ```
