How to print user role in Yii 2 GridView widget? I've tried with code:
public function getUserRole($id) { $roles = \Yii::$app->authManager->getRolesByUser($id);
$role = '';
foreach($roles as $key => $value)
{
$role = $key;
}
return $this->role = $role;
}
in User model class but it's not working. Each user has assigned only one role. Many thanks for any help.