0

I am developing an web backend for swiggy type of application. In that back-end i want to display all restaurants added by that particular partner user in header and that drop-down will display on all pages, so i want to do that get all restaurants and store on some place so that header can access and display it on every page. so how to do this? I am try to execute below code

if (Auth::guard('partner')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
        // if successful, then redirect to their intended location
        $user = $userId = Auth::id();
        echo '<pre>';
        print_r($user);
        exit;
        return redirect('partners/employees');
    }

but it gives me error not able to get user id. i want to display user's restaurants list which is added by current user in system on every page header as dropdown list. so how can i achieve this.

Adarsh Bhatt
  • 548
  • 1
  • 9
  • 30

2 Answers2

0

you can access user id like this

$userId = Auth::guard('partner')->user()->id;
Shailendra Gupta
  • 1,054
  • 6
  • 15
0
Auth::user()->id;

Also... this is weird. Typo?

$user = $userId = Auth::id();

$userId = Auth::user()->id;
$user = Auth::user();
Shevy
  • 310
  • 4
  • 13