Laravel 5 has ORM models by default in app folder. I want to move these into app/models. When I do that then these classes are not found anymore.
How to make Laravel fin
Say you want to move the models to app/Models
For each model change :
namespace App;
to
namespace App\Models;
Check these files and search especially app\User
app/Http/Controllers/Auth/RegisterController.phpconfig/auth.phpconfig/services.phpdatabase/factories/ModelFactory.phpdatabase/factories/UserFactory.phpAnd change App/ModelExample to App/Models/ModelExample
Run composer dump-autoload
Add "app/models" to composer.json's classmap autoload section
"autoload": {
"classmap": [
"database",
"app/models"
]
}
Afer moving all files in the models folder. What you need to do is run:
composer dump-autoload
This worked for me. :)
Just create a folder named Models and move your files into it. After that, change the namespace of the models from just App to App\Models (update the usages as well) and run composer dump-autoload.
After doing @Saint Play steps. I had to do php artisan config:clear. Then it worked !