Class 'App\Http\Controllers\Auth\User' not found

clund picture clund · Oct 30, 2017 · Viewed 14.1k times · Source

I'm trying to implement Socialiate for Laravel 5.5 using this guide https://scotch.io/tutorials/laravel-social-authentication-with-socialite. Data is returned properly from the provider, but I am having trouble defining Use and Namespaces.

With this configuration:

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Socialite;

The result is:

Class 'App\Http\Controllers\Auth\User' not found

Triggered by:

$authUser = User::where('providerId', $user->id)->first();

But, if I add App\User:

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\User;
use Socialite;

The result is:

Class 'App\Http\Controllers\Auth\Auth' not found

Triggered by:

Auth::login($authUser, true);

Any help is much appreciated.

Answer

Samuel James picture Samuel James · Oct 30, 2017

You didnt import Auth namespace the right way.

The proper namespace is Illuminate\Support\Facades\Auth;

Add use Illuminate\Support\Facades\Auth; at the top of your class.