Skip to content

Commit 3ff9932

Browse files
authored
Merge pull request #11 from amiryousefi/Enhance-HasRoles-trait
Enhance has roles trait
2 parents 2745cd5 + 1c9dc1c commit 3ff9932

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Traits/HasRoles.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ trait HasRoles
88
{
99
public function role()
1010
{
11-
return $this->belongsTo(Role::class)->first();
11+
return $this->belongsTo(Role::class);
12+
}
13+
14+
public function getRoleNameAttribute(){
15+
return $this->role()->first() ? $this->role()->first()->name : null ;
1216
}
1317
}

0 commit comments

Comments
 (0)