jeudi 27 août 2015

Laravel 5 Splitting up a Model

PHP noob here.

I have an Item model which is responsible for adding items to my cart.. However the items I'm adding are not simple products. Each item type has a complicated formula for generating a customized quote based on the users selections and personal discount, etc.

The simplest way I can think to do this is to have functions for each product within the item model with each unique formula in. However, this will get messy very fast.

What is the best practice for splitting these into separate files and then including those files in the model, just for keeping my code clean and seperate?

So for example I have aircraft, cars, boats as categories, each product within each category has it's own formula but I at least want to keep aircraft formulas separate from boat for ease of reading.

Is it best to create an aircraft model, boats model etc and have them all use the items DB table and then once they are added I can control them all from the Item model?

I may have just answered my own question, but I don't know :D Learning loads but still a noob.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Jo0pCB
via IFTTT

Aucun commentaire:

Enregistrer un commentaire