miladhspr/laravel-encryptable is a Laravel package for laravel automatic attribute encryption.
It currently has 0 GitHub stars and 102 downloads on Packagist (latest version v0.0.4).
Install it with composer require miladhspr/laravel-encryptable.
Discover more Laravel packages by miladhspr
or browse all Laravel packages to compare alternatives.
Last updated
laravel-encryptable is a package that provides automatic encryption and decryption of model attributes in Laravel applications. This ensures that sensitive data is stored in an encrypted format in the database and is automatically decrypted when accessed within your application.
$encryptable property on the model.where, whereHas, orWhere, etc., work seamlessly with encrypted attributes..env file, ensuring that only your application can access it.Run the following command to install the package via Composer:
composer require miladhspr/laravel-encryptable
You can publish the package's config file with the following command:
php artisan vendor:publish --provider="Miladhspr\LaravelEncryptable\EncryptableServiceProvider"
Set ENCRYPTION_ENABLED=true or ENCRYPTION_ENABLED=false in your .env file to enable or disable encryption globally.
Use the Encryptable trait in your model and specify the $encryptable attribute for fields to be encrypted:
namespace App\Models;
use Miladhspr\LaravelEncryptable\Traits\Encryptable;
class User extends Model
{
use Encryptable;
protected $encryptable = ['email', 'phone_number'];
}
When inserting or updating records, specified attributes in $encryptable are automatically encrypted:
User::create([
'name' => 'John Doe',
'email' => '[email protected]',
'phone_number' => '1234567890',
]);