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

This commit is contained in:
Andras Bacsai 2024-05-15 11:41:11 +02:00
parent 444dffb458
commit 1d9d6c899d

View File

@ -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');
}
}