You could just add a middleware to the any route that redirects if the method is wrong
Oct 18, 2021
5
Level 3
Route handling best practice
Hello, im curious as to how would anyone solve this routing example and whats the best practice. Essentially i would like only the post method to be available and every other method to redirect to home or maybe throw a 404. My solutions is the following but im not sure its the correct one.
Route::any('/myRoute/myAction', [MyController::class, 'redirectHome']);
Route::post('/myRoute/myAction', [MyController::class, 'myAction']);
Level 102
Please or to participate in this conversation.