Isn't this just a controller action parameter? Can you elaborate a bit?
Jun 24, 2016
6
Level 1
POST with one extra parameter
I need to pass a JSON and 1 extra parameter to my API.
I have this route $app->post('api/v1/event','EventController@saveEvent'); But I need to pass one extra parameter like: $app->post('api/v1/event/{api}','EventController@saveEvent');
I need to get the value in "api" and then the JSON. Is that possible?
Level 54
Maybe optional params aren't allowed for post routes? Try this...
routes:
$app->post('api/v1/event','EventController@saveEvent');
$app->post('api/v1/event/{api}','EventController@saveEvent');
controller:
public function saveEvent(Request $request, $api = NULL) {
// If included in the request url, $api will be set to that value, else null by default.
// json is contained within $request->input
}
1 like
Please or to participate in this conversation.