123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Models;
- use Tymon\JWTAuth\Contracts\JWTSubject;
- use Illuminate\Notifications\Notifiable;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Foundation\Auth\User as Authuser;
- class User extends Authuser implements JWTSubject
- {
- use Notifiable;
- // use SoftDeletes;
- // protected $fillable = ['nickname','realname','phone','hard_num','simple_num','old_num','promise_num','status','created_at','','',''];
- //
- // protected $hidden = ['password'];
- // Rest omitted for brevity
- /**
- * Get the identifier that will be stored in the subject claim of the JWT.
- *
- * @return mixed
- */
- public function getJWTIdentifier()
- {
- return $this->getKey(); /*自己可以定义的生成token的参数,我用的是将主键加密*/
- }
- /**
- * Return a key value array, containing any custom claims to be added to the JWT.
- *
- * @return array
- */
- public function getJWTCustomClaims()
- {
- return [];
- }
- // public $timestamps = false;
- //定义表
- protected $table = "user";
- //定义主键
- protected $primaryKey = "id";
- public function get_address(){
- return $this->hasOne(Address::class,'user_id');
- }
- public function get_dwbs_user(){
- return $this->hasManyThrough(DwbsUser::class,User::class,'dwbs_id','id','user_id','id');
- }
- public function enroll(){
- return $this->hasOne(Enroll::class,'user_id','id');
- }
- }
|