I already have a database in sql-server and I would like to create the models for laravel from the tables that I already have in my database.
How can I achieve it?
I already have a database in sql-server and I would like to create the models for laravel from the tables that I already have in my database.
How can I achieve it?
You can use the following extension: Model generator .
Installation (Composer):
Global Composer:
Local Composer:
Use and execution:
You add the provider (provider)
Laracasts\Generators\GeneratorsServiceProvider
to yourconfig/app.php
.You execute the following command from your terminal (being in the project):
I also had the same problem but found that you only have to create a model for each table and handle it through the controllers, these videos helped me a lot:
With mysql-workbench (GNU License) you can reverse engineer a MySQL database to get the database layout, same with enterprise-architect to Oracle database, for SQL Server try Microsoft Office Visio Professional .
More information: Database Reverse Engineering .
I found this generator and it has helped me a lot https://github.com/krlove/eloquent-model-generator , the instructions are also there and they are explained better than I could do it, and yes, it pulls the fields from the base of data (although I use it with postgres) I hope it will be useful.