Resource controllers and endpoints

The recommended table from Laravel.

Very useful to apply in other frameworks or custom apps too:

Actions Handled By Resource Controller

Route name is bound as “class”.”method” on the controller file. If you are using client-sided rendering you only need to use the REST methods (since the server does not return forms)

VerbPathActionRoute Name
GET/resourceindexresource.indexREST
GET/resource/createcreateresource.create
POST/resourcestoreresource.storeREST
GET/resource/{id}showresource.showREST
GET/resource/{id}/editeditresource.edit
PUT/PATCH/resource/{id}updateresource.updateREST
DELETE/resource/{id}destroyresource.destroyREST

Summary:

Route NameAction
resource.index/resourceDisplay a listing of the resource.
resource.create/resource/create Show the form for creating a new resource (not valid for REST).
resource.store/resourceStore a newly created resource in storage.
resource.show/resource/{id}show
resource.edit/resource/{id}/editShow the form for editing the specified resource (not valid for REST)
resource.update/resource/{id}Update the specified resource in storage.
resource.destroy/resource/{id}destroy

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s