Automatically encrypt and decrypt database table fields.
You can install the package via composer:
composer require venturedrake/laravel-encryptable
You can publish the config file with:
php artisan vendor:publish --provider="VentureDrake\LaravelEncryptable\LaravelEncryptableServiceProvider" --tag="config"
Add the trait to your model and your encryptable rules.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use VentureDrake\LaravelEncryptable\Traits\LaravelEncryptableTrait;
class Person extends Model
{
use LaravelEncryptableTrait;
/**
* Laravel Encryptable Rules
*
* @var array
*/
protected $encryptable = [
'first_name',
'last_name',
];
...
}
Now when you store, update or read from the model the first_name and last_name fields will automatically be encrypted and decrypted.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.