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
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;
php artisan config:cache php artisan config:clearIf 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,
],
I was using Laravel 8x and found a simple idea using at the top of the <your_controller>.php
use App\Models\User
if you are using user.php model file into folder Models/user.php then you need to change in follwing file so You will not get any Error
where to change if we create Model Folder in App\http ??
changer in folowing path ---
1 Config - - auth.php - search for users key change ---> app\user TO app\Models\user
2 venedor/composer/ -autoload_classmap.php ----> BAse path (app\user TO app\Models\user) -autoload_static.php ----> BAse path (app\user TO app\Models\user)
I finally was able to resolve it by changing this the following code.
array (
'driver' => 'eloquent',
'model' => 'App\\Models\User',
),
What happened is that you changed the location of the file user.php.
Your system is still looking for the file user.php in the old location. You need to give the system the right road to the file.
I gess you have to change the the code from 'model' => App\User::class, to
'model' => App\Models\User::class,
This problem is one of the config and cache settings, and by executing the following commands in the terminal, 90% of the problem will be fixed
config:clear
cache:clear
config:cache
php artisan in the commands, otherwise, the commands would not be recognized. So, the correct commands would be php artisan config:clear, php artisan cache:clear, and php artisan config:cache. Thanksi just change use app\User to use App\User and it works
I have faced same issue and get rid from it by matching the name (App\Models\User)in homecontroller and config->auth.php file ('model' => App\Models\User::class,). App\Models\User is not same in my case Modal in auth file is first letter capitalize and in controller modal is in small letters. Please match the upper & lowercase letters also
Error:
Error: Class "App\User" not found/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factories/Factory.php:806
update User model
class User extends Authenticated
{
/** @use HasFactory<UserFactory> */
use HasApiTokens;
use HasFactory;
use Notifiable;
protected static function newFactory(): Factory|UserFactory
{
return UserFactory::new();
}
update UserFactory
class UserFactory extends Factory
{
protected $model = User::class;
...