Back

I was watching a talk recently about testing your code (it might have been @nunomaduro 's talk on Pest 3?) that mentioned that your controllers should ONLY have the resource / CRUD methods in them.

I'm building a more complex app that has routes related to a user taking a test that's doing a lot more than just those methods. If not in a controller, where should those methods be placed?

I have a TestSessionController that handles all of the routes for the next question and grading the test and the questions. I am moving a lot of the functionality out of the controller and into Action classes, but I still use different methods in my controller to call those actions.

Or was that just an example of what could be done, and not necessarily a "best practice" sort of thing? Any help would be great!

3

245

In response to @dcblogdev

Thanks for the video! I'll check it out tonight.

1

125

  • No matching results...
  • Searching...

/ 1000

@dcblogdev

Thank you so much for that video. I wish I had watched this a few months ago and maybe this project I’m wrapping up could have been made cleaner.

I don’t know if I would want to make EVERYTHING CRUD but it definitely gives me ideas in how to clean things up.

1

289

I always love these type of videos, can change how you build applications.

471