Laravel 5 - relocated user model in application / models causing autoload problems

Work on an inherited Laravel Spark project containing two custom models.

One of them is the standard Spark model inside the application directory, and the other is inside the App / Models. I combined the two models and updated auth.php to refer to the User model inside the Models directory, but the dump-autoload linker says it cannot find the App / User model.

How can I tell the autoloader that the User model no longer exists, but instead in the model directory?

Edit:

I changed the namespace to App / Models, but still getting an error:

class_parents(): Class App\User does not exist and could not be loaded 

In my terminal, when running dump-autload

Second edit:

Corrected, did not understand that so much was indicated on the namespace. Selected and replaced with App \ User and sorted the problem.

+6
source share
3 answers

You need to change the namespace of the User model:

 namespace App\Models; 
+2
source

change the namespace and use this as

 namespace App\Models; 
+2
source

Try renaming the namespace. :)

 namespace App\Models; 
+2
source

Source: https://habr.com/ru/post/1012585/


All Articles