jivemonkey2000 / larabits
一组有用的Laravel工具。
v1.0.3
2017-03-01 13:54 UTC
Requires
- php: >=5.6.4
This package is not auto-updated.
Last update: 2024-09-28 20:20:10 UTC
README
一个存放有用的Laravel工具的集合的地方。
Eloquent
属性加密
只需几个步骤即可为您的Eloquent模型添加属性级加密
- 在类顶部导入
Larabits\Eloquent\AttributeEncryption - 添加一个
$encrypt数组属性,并用您要加密的属性填充它 - 将
use AttributeEncryption添加到您的Eloquent模型中
就像这样
<?php use Illuminate\Database\Eloquent\Model; use Larabits\Eloquent\AttributeEncryption; class User extends Model { use AttributeEncryption; /** * The attributes that should be encrypted. * * @var array */ protected $encrypt = [ 'email', 'secret', ]; }
如果需要,可以通过使用您的 .env 文件设置一个 APP_ENABLE_ENCRYPTION 常量 false 来启用和禁用加密。这在测试时很有用,例如在使用 seeInDatabase('table',['foo' => 'bar']); 时。
安装
要安装Larabits,请将其添加到您的 composer.json 文件中,或者从项目根目录执行 composer require jivemonkey2000/larabits。
composer require jivemonkey2000/larabits