#Should the post request and get request need separate controllers?
9 messages · Page 1 of 1 (latest)
Most likely, yes.
Whatever works for you 🙂 There are different philosophies and no single right answer. Personally I use resource controllers for crud operations, and single action controllers for anything non-standard.
My answer was mostly based on the fact that it's a rather vague question tbh.
I assumed you meant multiple endpoint methods pointing to the same controller method
You'll get better answers if you ask a more specific question.
So I have this controller for registration, which has get/post. What I did was use the same class file but a different method for each request type.
I assume two routes, one that shows the registration page, the other is the POST one and receives the input / registers users? Then yes, that's quite a common approach, see for example Breeze; https://github.com/laravel/breeze/blob/2.x/stubs/default/app/Http/Controllers/Auth/RegisteredUserController.php
thanks
Nice, I guess I am in the right path then.