vendredi 2 juin 2017

How can I shorten controller methods that is called by Route Class? (Laravel)

I have a journal like site. It has lots of Models: Post, User, UserJournal, Comment as well as Journal. To render Journals I use getJournal method of Journal class. Because getJournal method calls methods from all Models, it is soo long.

I have read that methods should be as short as possible. Laravel methods, for example, are really short. How can I shorten my methods called from Route class?

One possible solution I come up is to increase the size of __construct method of Journal class. So that I will gather all information here; $posts of the journal, $userjournals of the user, etc.

What do you suggest?



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

Aucun commentaire:

Enregistrer un commentaire