'datetime', ]; protected $appends = [ 'avatar_url' ]; // 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 []; } public function shop() { return $this->hasOne(Shop::class, 'id', 'shop_id'); } public function wechatUser() { return $this->hasOne(WechatUser::class, 'id', 'wechat_user_id'); } public function agentNum() { return Customer::where('agent', BoolEnum::YES)->where('shop_id', $this->shop_id)->count(); } //修改日期时间格式 protected function serializeDate(\DateTimeInterface $date) { return $date->format('Y-m-d H:i:s'); } public function getAvatarUrlAttribute() { $avatar = $this->avatar; if (!$avatar) { return ''; } return Helps::fullUrl($avatar); } public function enablePlatformAgent() { return $this->platform_agent == BoolEnum::YES; } public function isAdmin() { return $this->level == SellerLevel::MASTER; } }