1. Home
  2. Laravel
  3. Route resource
#laravel#route

Using resource method will create a complete list of routes required for listing, creating, storing, editing and removing items.

Route::resource('items', 'ItemsController'); // this will generate all the routes listed below

/*
    
    // DISPLAY
        GET     /items                      ItemsController@index       Show all Items
        GET     /items/{itemID}             ItemsController@show        Show a single Item with an id of {itemsID}

    // CREATE
        GET     /items/create               ItemsController@create      Show form to create a new Item
        POST    /items                      ItemsController@store       Add new Item

    // EDIT
        GET     /items/{itemID}/edit        ItemsController@edit        Show form to edit an existing Item with an id of {itemID}
        PATCH   /items/{itemID}             ItemsController@update      Update an exiting Item with an id of {itemID}

    // REMOVE
        DELETE  /items/{itemID}             ItemsController@destroy     Delete project with an id of {itemID}

*/
copy
Full Laravel cheatsheet
Sitemap Git repository