Should I create a Controller or just a class if Model is accessed but not view is involved?

StackOverflow https://stackoverflow.com/questions/21127769

Question

I am building an invoicing app with Laravel. Invoices consist (among other things) of one or many Items (invoice lines).

Invoice and invoice Items have separate database tables and models. However, Items are created together with their parent Invoice, in the same form and view.

So, views and controller make sense for Invoice... but what about Items? Where should I place all my logic processing the form, displaying errors or whatever related to Items? In the same InvoiceController, in a separate class...?

Sorry if this is a repeated question, I've tried to find an answer without any luck.

Était-ce utile?

La solution

It would be logical to include all your processing for invoice items within a invoice controller. In the MVC pattern it is not necessary to have a controller and view specific for each of your models. This would be an anti-pattern.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top