0

I want to get array elements value in Auth::User(). After {{dd(Auth::User()}} output of array shows many elements:

  Admin {#474 ▼
  #guard: "admin"
  #fillable: array:4 [▶]
  #hidden: array:2 [▶]
  #connection: "mysql"
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []

I'm trying to access using Auth::user()->guard; this but it does not work for me. Please tell me how to get this. Many Thanks in Advance.

2

1 Answer 1

1

Check this function. It checks the current logged in user against all guard. Here I used dd to dump the logged in guard. But you can extract and utilize it to do whatever you want.

  $guards = array_keys(config('auth.guards'));
  foreach ($guards as $guard) {
    if(Auth::guard($guard)->check()) dd($guard);
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.