Model, View and Controller "Multipurpose" - Laravel 5.1

Asked

Viewed 254 times

2

Good morning, I have in my application 10 different tables, but it has the same structure... id | nome | descricao. For each table I have in the Model, the Controller and the Views registration, listing and editing. I wonder if you have any way to use the same Model, Controller and View to manage all this, or if you have to minimize it somehow, as it has many similar files and I don’t think this is really necessary, just lack knowledge.

  • Perhaps, with a little creativity, this can help you https://laravel.com/docs/master/routing#route-model-Binding

1 answer

2


Well, I’m not sure if it’s the best solution, but it suits me very well... I just joined all the tables and added a "type" column. As the data volume of each one is quite low I think it will work well.

  • Create a table that has an additional 'type' column in place of many with similar structure is easier to maintain and implement, today there are 10 tables in the future this number multiplies :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.