What rules of thumb(personal or industry based) do you follow when building applications in Laravel?
For further actions, you may consider blocking this person and/or reporting abuse
What rules of thumb(personal or industry based) do you follow when building applications in Laravel?
For further actions, you may consider blocking this person and/or reporting abuse
Jess Lee -
Etienne Lebarillier -
Scofield Idehen -
Hanzla Baig -
Top comments (3)
I follow this rule: Controllers are strictly for resource I/O, so a controller at max can only have seven public methods (one for each Restful actions). If it's not one of the following
... I move it to a separate controller. So let's say an article can be upvoted; instead of a custom
ArticleController@upvote
method, I create anUpvoteController@store
instead. Take note that an upvote is not a concrete Eloquent model, but it can still be considered a resource.TL;DR: A Controller doesn't necessarily have to map with an Eloquent model. Use it to group resource-related logic so you don't have to write custom controller methods.
Edit: I may have butchered that concept, I'm quite tired and can't type properly lol.
Nice!. Please add a number so we can all keep track of the rules. LOL!
OK, I'll go first: