lundi 4 février 2019

How to refactor laravel application code effectively

I'm in a position to refactor my laravel 5.4 app codes due to some problems: Code complexity, lack of oo design experience etc.

I have read that controller codes should be as short as possible (it is claimed that they are glue code parts).

Q1: I have some library like codes. These library functions/classes should be in the related Model classes, or should I have extra classes which make use of Model classes?

Q2: If I don't need extra classes (so model classes are enough), should I call these business logics from blade files, or from controllers? (Business logics in controllers make them quite large and complex).

Example: In a controller function, I evaluate post dataset with a query. After that I need some business logic for each post like effectiveValueOfPost($post). Should I call it from controller and pass it to the related view, or call it from blade file.

Thank you.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2D5oVf7
via IFTTT

Aucun commentaire:

Enregistrer un commentaire