I want to get current userId from database without Auth::() and I don't want to get it from route like '/xxx/{id}'
Is there any other way to get the userId without Auth::()?
eg. $userId = User::where('id', $id)->pluck('id');
Here is my auth::controller declaration :
public function getLogout(Request $request)
{
$redis = \Redis::connection();
$user = $request->user();
if ($user) {
$userID = $user->id;
}
// $userId = User::where('id', $id)->pluck('id');
dd($userID);
// $userId=Auth::user()->id;
$userSessions = $redis->smembers('users:sessions:' . $userId);
$currentSession = Session::getId();
foreach ($userSessions as $sessionId) {
if ($currentSession == $sessionId) {
continue;
}
$redis->srem('users:sessions:' . $userId, $sessionId);
$redis->del('laravel:' . $sessionId);
}
Auth::logout();
return redirect()->route('main');
}