| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?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','is_vip','is_auth','remember_token','ycode'
- ];
- /**
- * 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)
- {
- $this->attributes['password'] = bcrypt($value);
- }
- }
|