secure() ? "https" : "http"; if (!$this->avatar) { switch ($this->sex) { case "男": $this->avatar = "/images/male.png"; break; case "女": $this->avatar = "/images/female.png"; break; } } return $this->avatar ? $protocol . "://" . request()->getHost() . $this->avatar : $this->avatar; } public function getTypeNameAttribute() { $type_name = $this->type; switch ($this->type) { case "teacher": $type_name = "管理老师"; break; case "manager": $type_name = "项目经理"; break; } return $type_name; } public function guardName() { return self::GUARD_NAME; } // 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(); } /** * Return a key value array, containing any custom claims to be added to the JWT. * * @return array */ public function getJWTCustomClaims() { return []; } /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'type', 'name', 'sex', 'username', 'password', 'openid', 'unionid', 'mobile', 'birthday', 'avatar', 'order_status_ability' ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'verified_at' => 'datetime', ]; public function managerProjects() { return $this->hasMany(ManagerProject::class, "manager_id", "id"); } public function projects() { return $this->hasManyThrough(Project::class, ManagerProject::class, "manager_id", "id", "id", "project_id"); } }