Skip to content

Commit

Permalink
Merge pull request #11 from amiryousefi/Enhance-HasRoles-trait
Browse files Browse the repository at this point in the history
Enhance has roles trait
  • Loading branch information
amiryousefi committed Apr 11, 2021
2 parents 2745cd5 + 1c9dc1c commit 3ff9932
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Traits/HasRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
}
}

0 comments on commit 3ff9932

Please sign in to comment.