Exemple #1
0
 /**
  * Add hook for model
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     Item::creating(function ($item) {
         if (!isset($item->sym_pass)) {
             return false;
         }
         $bin_iv = random_bytes(16);
         $val = openssl_encrypt(serialize($item->val), DEF_METHOD, $item->sym_pass, 0, $bin_iv);
         $item->val = $val;
         $item->iv = base64_encode($bin_iv);
     });
 }