Get user ID for database insert
Do you want to get the username, as the variable name suggests?

$uname = User::load($userCurrent-&gt;id())-&gt;name-&gt;value;


Your question does not make sense, why load the user with the id to get the id, you already have?