使用 Laravel 4 自动生成模型类(也就是使用带有 L4 的现有数据库)

2021-12-26 00:00:00 php laravel eloquent

我在 MySQL Workbench 中设计了我的数据库,并设置了我所有的外键等

I've designed my database in MySQL Workbench, and have all my foreign keys setup, etc.

我想在 Laravel 4 中使用这个 DB 模式,但是从文档中没有任何文字可以使用现有的数据库表集.根据我的理解,其他框架(例如 Cake 及其烘焙")允许您根据数据库中已有的表自动生成模型类.

I'm wanting to use this DB schema with Laravel 4, however from the docs there is no word of any sort of ability to work with an existing set of database tables. From my understanding, other frameworks such as Cake with its 'Baking' allow you to automatically generate your model classes based on the tables already in your database.

我到处环顾四周,根本看不到 Laravel 4 的任何相关信息.我发现最接近的是 Jeffrey Way 的用于工匠的 Generator 包,但是这只创建了基本模型,并没有检测到已建立的模型外键关系.

I've looked around everywhere and cant see anything about this at all for Laravel 4. The closest thing I've found is Jeffrey Way's Generator package for artisan, however this only creates the base model, and doesn't detect established foreign key relationships.

这在 Laravel 4 中是可行的,还是我必须手动完成?

Is this even possible with Laravel 4 or am I going to have to just do it all manually?

推荐答案

好消息是 Antonio 刚刚完成了他的 MySQL WorkBench 到 Eloquent ORM 转换器这是一个很好的解决方案,但对我来说有点晚了,但可能对你有很大帮助.

The good news is that Antonio just finished his MySQL WorkBench to Eloquent ORM converter This is a beautiful solution but comes a way to late for me but may help you a lot.

更新:该链接目前无效.网页上写着我们正在重新设计东西,很快就会回来!".我已经给 antonio 发了一封电子邮件,询问他什么时候可以再次提供这项服务.

Update: The link isn't working in the moment. The wabpage says "We are redesigning things, will be back soon!". I allready sent antonio an email asking him, when this service will be available again.

安东尼奥说它会回来,但没有预计到达时间.我们必须等待..

Antonio said that it'll be back but there is no estimated time of arrival. We have to wait..

相关文章