Refactor User model role() method to use data_get() for better readability

This commit is contained in:
Andras Bacsai committed 2024-05-15 11:41:11 +02:00
1 parent 444dffb458
commit 1d9d6c899d
1 file changed
+2 -1
+2 -1
View File
@@ -183,6 +183,7 @@ class User extends Authenticatable implements SendsEmail
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');
}
}