I moved over to Laravel 5 from Laravel 4. One major change I'm seeing is that all model files must be placed under the /app
directory.
How do I configure my laravel 5 installation so that I can place my model files under /app/Models
and also use the models in the usual FooModel::with(...)
(for example) way?
you just need to namespace the models accordingly.
namespace App\Models\User
and wherever you may need to use them just reference them with the correct namespace.
use App\Models\User
Add the folder to the composer.json
classmap:
"autoload": {
"classmap": [
"database",
"app/Models"
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With