In my laravel project, when i want to get the current user ID, i use this logic bellow:
public function showuserid() {
$userid = Auth::id(); //this is the simplest way i found of how to get the current user's id
return view('perfil/mostrarid')->with('mostrarid', $userid);
}
My problem is, my table 'users' in my database, has an extra column called 'credencial'.
I tried to do $userid = Auth::credencial(); but it doesn't work and i get an error:
Method Illuminate\Auth\SessionGuard::credencial does not exist.
Can i get that value using Auth somehow? Is there any other way, as simple as Auth, to get the value?
Auth::credencial()deosn't works because credencial it's not an Auth method. What I suggest was thisAuth::user()->credencial. And what I mean it's ifAuth::user()reurns null,Auth::id()will return null too. If it's there an authenticated user ,Auth::user()will return the user table fields