diff --git a/src/Traits/HasRoles.php b/src/Traits/HasRoles.php index 281c84f..9d18873 100644 --- a/src/Traits/HasRoles.php +++ b/src/Traits/HasRoles.php @@ -8,6 +8,10 @@ trait HasRoles { public function role() { - return $this->belongsTo(Role::class)->first(); + return $this->belongsTo(Role::class); + } + + public function getRoleNameAttribute(){ + return $this->role()->first() ? $this->role()->first()->name : null ; } }