将Laravel 5 Eloquent模型移到其自己的目录中 [英] Move Laravel 5 Eloquent models into its own directory

查看:71
本文介绍了将Laravel 5 Eloquent模型移到其自己的目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Laravel 5默认在应用程序文件夹中具有ORM模型.我想将这些移动到应用程序/模型中.当我这样做时,将不再找到这些类.

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.

如何使Laravel从应用程序/模型中找到雄辩的ORM模型?

How to make Laravel find the Eloquent ORM models from app/models?

推荐答案

只需创建一个名为Models的文件夹,然后将文件移动到其中即可.之后,将模型的名称空间从仅App更改为App\Models(也更新用法)并运行composer dump-autoload.

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.

这篇关于将Laravel 5 Eloquent模型移到其自己的目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆