laravellaravel-5

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


Solution

  • 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;