search

Home  >  Q&A  >  body text

router - How to get route name in Laravel?

Route::resource('photo', 'PhotoController');

//GET           /photos                    index
//GET           /photos/create            create
//POST          /photos                    store
//GET            /photos/{photo}            show
//GET            /photos/{photo}/edit    edit
//PUT/PATCH        /photos/{photo}            update
//DELETE        /photos/{photo}            destroy

The corresponding route names are:

photo.index
photo.create
photo.store
photo.show
photo.edit
photo.destory

Assume the domain name is: www.longlongago.top

www.longlongago.top/photos

How to get its routing name photo.index
based on

www.longlongago.top/photos
给我你的怀抱给我你的怀抱2800 days ago575

reply all(2)I'll reply

  • 迷茫

    迷茫2017-05-16 16:49:45

    Laravel uses the restful architecture style. If you are not sure about it, you can check it online.
    resource is a resource route that can point to the corresponding method under the controller according to the request method
    For example: directly access the URL www.longlongago.top/photos, first determine that this is a get request, so the program will The default method to find index

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-16 16:49:45

    Route::currentRouteName()

    reply
    0
  • Cancelreply