belongsTo(Currency::class); } public function getCurrencyNameAttribute() { return $this->currency()->value('name'); } public function getHeadPortraitAttribute() { $user = Users::find($this->attributes['author']); if (!empty($user)) { return $user->head_portrait; } return ''; } public function getAuthorNameAttribute() { $user = Users::find($this->attributes['author']); if (!empty($user)) { return $user->nickname; } return ''; } }