Do I need to create the models for the tables in the database? Laravel 5.1

1

I came up with the following doubt, in a project that I am doing I have about 25 tables for my database. My .sql file is already ready with the tables and I want to know if I have to create a model in Laravel for each table, I want to know because it would be a bit of a tired job since in my sql my relations are already directly and I do not want to make a relationship by relation from 0. Or also if there is some way that the Laravel believes me those relationships directly.

    
asked by Luis Morales 08.10.2016 в 05:17
source

1 answer

2

Responding to the question as such, it is NOT necessary to create the models for each table, it all depends on the design of your application, the advantage of having the models is to have the preloaded relationships as properties and the methods offered by these relationships, which will save hundreds or thousands of lines of code.

Not all tables need a model, such as pivot tables or polymorphs.

There are some packages like Eloquent model generator and Laravel model generator that can help you generate models and relationships from a database schema, but I do not know how good they are, I have not used them.

    
answered by 08.10.2016 / 18:26
source