Refactor User model role() method to use data_get() for better readability
This commit is contained in:
parent
444dffb458
commit
1d9d6c899d
@ -183,6 +183,7 @@ public function role()
|
||||
if (data_get($this, 'pivot')) {
|
||||
return $this->pivot->role;
|
||||
}
|
||||
return auth()->user()->teams->where('id', currentTeam()->id)->first()->pivot->role;
|
||||
$user = auth()->user()->teams->where('id', currentTeam()->id)->first();
|
||||
return data_get($user, 'pivot.role');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user