1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Foundation\Auth\User as Authenticatable;
- use Illuminate\Notifications\Notifiable;
- use Spatie\Activitylog\Traits\LogsActivity;
- use Tymon\JWTAuth\Contracts\JWTSubject;
- class User extends Authenticatable implements JWTSubject
- {
- use Notifiable, SoftDeletes,LogsActivity;
- // 指定 LogsActivity 记录名
- protected static $logName = 'Model';
- protected static $logAttributes = ['*'];
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $fillable = [
- 'mobile', 'password', 'pid', 'tencent_im_user_id','sex','status','is_vip','is_auth','remember_token','ycode','latitude','longitude','online','notice_status','like_num','like_me_num','look_num','lock_pass','is_distory','registrationId','phoneModel'
- ];
- /**
- * The attributes that should be hidden for arrays.
- *
- * @var array
- */
- protected $hidden = [
- 'password',
- 'remember_token',
- ];
- public function getJWTIdentifier()
- {
- return $this->getKey(); // TODO: Implement getJWTIdentifier() method.
- }
- public function getJWTCustomClaims()
- {
- return [
- 'role' => 'user'
- ]; // TODO: Implement getJWTCustomClaims() method.
- }
- /**
- * 设置密码加密
- * @param $value
- * @return string
- */
- public function setPasswordAttribute($value)
- {
- file_put_contents('password.log','----'.date('Y-m-d H:i:s').'----'.var_export($value,true).PHP_EOL,FILE_APPEND);
- $this->attributes['password'] = bcrypt($value);
- file_put_contents('password.log','----'.date('Y-m-d H:i:s').'--加密后--'.var_export($this->attributes['password'],true).PHP_EOL,FILE_APPEND);
- }
- public function user_info()
- {
- return $this->belongsTo(UserInfoModel::class,'id','user_id');
- }
- }
|