小编Kal*_*nan的帖子

加密/解密laravel中的数据库字段

我正在通过访问器和更改器对Laravel中的DB字段值进行加密/解密,这在正常的雄辩事务中运行正常。

class Person extends Model
{
    use Notifiable;
    protected $table = 'person';

    public function getFirstNameAttribute($value)
    {
        return Crypt::decryptString($value);
    }
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = array();

    protected function user()
    {
        return $this->belongsTo('App\Models\User', 'useraccount_id', 'id');
    }
}
Run Code Online (Sandbox Code Playgroud)

但是加密和解密在以下情况下不起作用

  1. 雄辩的关系
  2. 数据库原始查询

工作中

$person = Person::find($person_id);
$person->firstName;
Run Code Online (Sandbox Code Playgroud)

无法运作

$user = User::find($user_id);
$user->person->firstName;
Run Code Online (Sandbox Code Playgroud)

php encryption laravel eloquent laravel-5

6
推荐指数
2
解决办法
5630
查看次数

将angulard.js集成在角度4中

在角度4中集成typed.js时,我得到以下错误.错误TypeError:WEBPACK_IMPORTED_MODULE_2_typed_js .Typed不是构造函数

我的组件是:

 import { Component, OnInit } from '@angular/core';
import { Typed } from 'typed.js';
@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {


  ngOnInit() {
    let options = {
          strings: ["Books.", "Cinema.", "Paintings.","Music."],
          typeSpeed: 100,
          backSpeed: 100,
          showCursor: true,
          cursorChar: "|",
          loop:true
        }

      let typed = new Typed(".typing-element", options);
  }

}
Run Code Online (Sandbox Code Playgroud)

我的Html是

<div class="container">
        <div class="home-header-title">
            <span class="title">what you like </span>
            <span class="typing-element"></span>
        </div>
    </div>
Run Code Online (Sandbox Code Playgroud)

angular

2
推荐指数
1
解决办法
871
查看次数

标签 统计

angular ×1

eloquent ×1

encryption ×1

laravel ×1

laravel-5 ×1

php ×1