You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.2 KiB
PHTML

2 years ago
<?php
namespace App\Libs;
use Carbon\Carbon;
use Illuminate\Support\Facades\Crypt;
trait EncryptUser
{
use Encryptable;
protected $_crypt_data = null;
protected $_cryptable = 'cryptable';
protected $encryptable = [
'birthday',
'gender',
'age',
];
public function setBirthdayAttribute($value)
{
$this->setAttribute('birth_day', $value);
}
public function setGenderAttribute($value)
{
$this->setAttribute('gender', $value);
}
public function setAgeAttribute($value)
{
$this->setAttribute('age', $value);
}
public function getBirthdayAttribute()
{
$value = $this->getAttribute('birthday');
if (empty($value)) {
return null;
}
return Carbon::parse($value)->format('Y-m-d');
}
public function getGenderAttribute()
{
$value = $this->getAttribute('gender');
if (empty($value)) {
return null;
}
return $value;
}
public function getAgeAttribute()
{
$value = $this->getAttribute('age');
if (empty($value)) {
return null;
}
return (int) $value;
}
}