在Laravel 5中从数据库创建模型 [英] Create Models from database in Laravel 5
问题描述
在Laravel 5中是否可以通过某种方式从数据库中生成模型?
Is there some way to generate models from database in Laravel 5?
generators包仅创建一个空模型.
The generators package only create an empty model.
推荐答案
There is a library Eloquent Model Generator which aim is creating Eloquent models classes using database tables as a source. It generates not only class stub, but relation methods, docblocks for magic fields, additional properties etc.
它提供了一个控制台命令php artisan krlove:generate:model ClassName
,用于每个调用生成一个类,但是您可以创建自己的命令来为数据库中的每个表调用该命令.
It provides a console command php artisan krlove:generate:model ClassName
for generating one class per one call, but you can create your own command to call this command for each table from your database.
这篇关于在Laravel 5中从数据库创建模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!