src/models/traits/Encryptable.php
public function setAttribute(string $key, string $value)
    {
        if ($this->valid($key, $value)) {
            $value = encrypt($value);
        }

        return parent::setAttribute($key, $value);
    }
public function setAttribute(string $key, string $value)
    {
        if ($this->valid($key, $value)) {
            $value = encrypt($value);
        }

        return parent::setAttribute($key, $value);
    }
public function setAttribute ( string $ key , string $ value ) { if ( $ this -> valid ( $ key , $ value ) ) { $ value = encrypt ( $ value ) ; } return parent :: setAttribute ( $ key , $ value ) ; }
Encrypt field value before inserting into database

@param string $key
@param string $value
@return mixed
Encrypt field value before inserting into database