定制 williamrox45/encrypt-model 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

williamrox45/encrypt-model

最新稳定版本:v1.0.3

Composer 安装命令:

composer require williamrox45/encrypt-model

包简介

The idea of this package is very simple; it is to add encryption to the model class attributes in an automated way.

README 文档

README

Simple trait to add in your models if you want to save it encrypted in the database, e.g: Store credit cards or any sensible data.

Requirements

Laravel 9+

Installation

composer require williamrox45/encrypt-model

Usage

use William\EncryptModel\EncryptModel;

class User extends Authenticatable
{
    use HasFactory;
    use Notifiable;
    use SoftDeletes;
    use EncryptModel; // <------

    /**
     * Attributes that should be encrypted
     * @var array<int, string>
     */
    protected $encryptable = [
        'name',
        'email',
    ];
$user = new User();

$user->name = "William";
$user->email = "will123@will123.com";

dump($user);
/**
 * These values will be save like this in the database
 * 
 * name = eyJpdiI6ImxyeVRBMGZrdGV2TDE1N1BkdzhRbFE9PSIsInZhbHVlIjoiUEd0QjlNbzNLMDBidXYySUtnRHB4dz09IiwibWFjIjoiMWY2ZDhjZjVhMmY5Mzk1ZGJlZDlhZWEyODk1ODg4NzIzOTdlZWE5MGY3ODhjNmM1ZDUzOGY2MzM5ZjEzOWI3YSIsInRhZyI6IiJ9
 * email = eyJpdiI6InhqamlKQVIxalFEdFNuRDZqNnZZTHc9PSIsInZhbHVlIjoicmgrMktBcDJwUllvZzFEZ3h6VDd3dlhKZXBPSWNuMi9TcHYrYnBZb2wrVT0iLCJtYWMiOiI2MGM0YmI5Mzc1ZjkxZjFkY2VkNDE3MzIwZDRjYjQ5ODc4ZDc1N2JjYTU2MmExNGNkYTlmZjk3NTU4ODM1Y2M5IiwidGFnIjoiIn0
 */
dd($user->name, $user->email);
/**
 * name = William
 * email = will123@will123.com
 */

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-14