paulehenri-l / laravel-encryptable
laravel-encryptable
1.0.0
2021-09-29 22:19 UTC
Requires
- php: ^7.3|^8.0
- laravel/framework: ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.1
- orchestra/testbench: ^6.21
- paulhenri-l/php-cs-config: ^1.0
- phpunit/phpunit: ^9.0
- symfony/var-dumper: ^5.3
README
在后台加密模型属性,以便它们在数据库中加密。
安装
composer require paulhenri-l/laravel-encryptable
使用方法
由于加密会使值变长,请考虑将列类型更改为文本。
<?php namespace App\Models; class Person extends Illuminate\Database\Eloquent\Model { use PaulhenriL\LaravelEncryptable\Encryptable; protected $encryptedFields = [ 'lastname', 'email' ]; } $person = new Person([ 'lastname' => 'I will be encrypted', 'email' => 'I will be encrypted too', ]); echo $person->lastname; // output will not be encrypted $person->lastname = 'I will be encryted too';