larapack / attribute-hashing
允许您定义在您的Eloquent模型中哪些属性应该被哈希。
v1.0.0
2015-11-27 11:07 UTC
Requires
This package is auto-updated.
Last update: 2024-09-06 08:54:00 UTC
README
允许您定义在您的Eloquent模型中哪些属性应该被哈希。
安装
使用Composer安装 composer require larapack/attribute-hashing 1.*
。
使用方法
首先将特质Manipulateable
和Hashable
添加到您的Eloquent模型中。
<?php
namespace App;
use Larapack/AttributeManipulating/Manipulateable;
use Larapack/AttributeHashing/Hashable;
class User
{
use Manipulateable;
use Hashable;
/**
* @var array List of attribute names which should be hashed
*/
protected $hash = ['password']; // set the attribute names you which to hash
//...
}
现在每次设置属性password
时,它将自动被哈希。
测试
$user = new App\User;
$user->password = 'secret';
echo $user->password // Here you will see the encrypted password