alessandrobelli
1 month ago
166
4
Tips

Best practices for CRUD model

Posted 1 month ago by alessandrobelli

Hi! I'm trying to stick to a CRUD model for my project, but sometimes is rather hard to do it. I have 2 questions about it:

  • where do I put the API methods? In an API controller or something like UserApiController.php? Or one big ApiController?
  • I can reduce every controller to a CRUD model easily, but since my projects are rather complicated I need several other functions. For example, I want display the result from a "survey" (case) and I need all the available inputs that were set from in the questionnaire (Project), for this I have a [email protected] which doesn't really stick to the CRUD model. Where should I put a function like that?
  • Where do I put the "Admin" functions that belongs to different models but are not CRUD? For example, if I want to delete all the project that belongs to a user, where do I put the method "deleteAllProjectByUser" ?

Please sign in or create an account to participate in this conversation.