Laravel – Resourceful Routing

Here are some notes for setting up resourceful routing.

Setting up the route file

This is an example for a controller called Projects.

Route::resource('projects', 'ProjectController');

Next to create this resourceful controller

I recommend using the -m to also create a model at the same time.

php artisan make:controller ProjectsController -r -m Project

The -r makes the controller resourceful which means it adds some boilerplate data for making get, post, put, etc…in that controller. The -m and following name and I’ve found that it’s easiest to add this for any controller I make at this stage rather than needing to do it later.

Leave comment

Your email address will not be published. Required fields are marked with *.