Laravel package to encrypt model attributes
famdirksen/laravel-model-encryption is a Laravel package for laravel package to encrypt model attributes.
It currently has 3 GitHub stars and 8.491 downloads on Packagist.
Install it with composer require famdirksen/laravel-model-encryption.
Discover more Laravel packages by famdirksen
or browse all Laravel packages to compare alternatives.
Last updated
This package can be used by simply adding a trait to the model you want to encrypt.
Via Composer
$ composer require famdirksen/laravel-model-encryption
To use this package in your own project, you need to add the trait to the model. In the following example we installed Larave 5.6 and ran php artisan make:auth to setup authentication.
You need to use the trait, ModelEncryption and add the protected $encryptable property to your User class, this way you'll enable model encryption on your user data.
app/User.php:
<?php
namespace App;
use Famdirksen\LaravelModelEncryption\ModelEncryption;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable, ModelEncryption;
protected $encryptable = [
'name',
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.