Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass parameter value in routes?

In my controller I have a delete method:

delete(String id, boolean confirmed)

Now in the routes I want to map two URIs accordingly:

GET /item/:id/delete           controllers.Application.delete(id:String, false)
GET /item/:id/delete/confirmed controllers.Application.delete(id:String, true)

(interesting part is the second parameter passed to the delete method depending on the URI)

This however gives me the following error:

 identifier expected but 'false' found. 

What am I doing wrong?

like image 788
stefan.at.wpf Avatar asked Nov 29 '12 19:11

stefan.at.wpf


1 Answers

Correct syntax is:

GET /item/:id/delete           controllers.Application.delete(id:String, confirmed:Boolean ?= false)
GET /item/:id/delete/confirmed controllers.Application.delete(id:String, confirmed:Boolean ?= true)
like image 121
biesior Avatar answered Nov 03 '22 17:11

biesior