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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top