Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class '\App\User' not found in Laravel when changing the namespace

I am having this error when moving User.php to Models/User.php

local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Class '\App\User' not found

vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php:126

like image 811
manshu Avatar asked Mar 06 '16 00:03

manshu


2 Answers

Go to config/auth.php and change App\User:class to App\Models\User::class.

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],

Also change the namespace of User.php model

namespace App\Models;
like image 79
Med Avatar answered Nov 17 '22 11:11

Med


If you are use the auth default on Laravel (php artisan make:auth), you have change the RegisterController on app/Http/Controllers/Auth/

use App\User;

to

use App\Models\User;

Also, for the rest of functionality, you have change the namespace on you User Model:

namespace App\Models;

And change config/auth.php

'providers' => [
'users' => [
    'driver' => 'eloquent',
    'model' => App\Models\User::class,
],
like image 13
Pablo Javier Vera Henríquez Avatar answered Nov 17 '22 11:11

Pablo Javier Vera Henríquez