loading...
markdown guide
 

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

ArticleController@index
ArticleController@create
ArticleController@store
ArticleController@show
ArticleController@edit
ArticleController@update
ArticleController@delete

... 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 an UpvoteController@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:

  1. To aid in the logical organization of my code, I link a set of features to related table(s) and logic such that it ends up having corresponding model(s), controller(s) and views. For example, say I have a set of features called "Admin {CRUD}" I'll create a table called "users" or "admins", then I'll create a model called "User" or "Admin", then a controller called "AdminController" with my logic going into the controller.
Classic DEV Post from Jun 19 '19

How important are math skills for software development?

Mbo profile image
A graduate of Electrical and electronics Engineering into backend and embedded systems development.