larapack/attribute-hashing

允许您定义在您的Eloquent模型中哪些属性应该被哈希。

安装: 940

依赖项: 0

建议者: 0

安全: 0

星标: 2

关注者: 2

分支: 0

开放问题: 0

类型:package

v1.0.0 2015-11-27 11:07 UTC

This package is auto-updated.

Last update: 2024-09-06 08:54:00 UTC


README

允许您定义在您的Eloquent模型中哪些属性应该被哈希。

安装

使用Composer安装 composer require larapack/attribute-hashing 1.*

使用方法

首先将特质ManipulateableHashable添加到您的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