Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yesenvidnath/f9fb211c93114447ce7441f3b2155e32 to your computer and use it in GitHub Desktop.
Save yesenvidnath/f9fb211c93114447ce7441f3b2155e32 to your computer and use it in GitHub Desktop.

Revisions

  1. yesenvidnath created this gist Nov 29, 2024.
    11 changes: 11 additions & 0 deletions Healper Class To Get The UserID By The Auth Token | Laravel
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    /**
    * Helper method to retrieve the authenticated user's ID.
    */
    protected function getAuthenticatedUserId()
    {
    // Retrieve the authenticated user
    $user = Auth::user();

    // Check if the user is authenticated and return the user_ID
    return $user ? $user->user_ID : null;
    }