Skip to content
Advertisement

Ways to write Laravel routes

Is there a better way to write these routes? It seems I am repeating the same controller in my route files.

JavaScript

Advertisement

Answer

You can use a resource route, where you specify a subset of actions in the controller.

JavaScript

You can also use the --model option when generating a controller with the stubbed out CRUD methods.

JavaScript

Result:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement