0
// My routes
Route::controller('api/v1/offer/{id?}', 'restful\OfferController');
Route::controller('api/v1/offer/{id}/qualifiers', 'restful\OfferController');
Route::controller('api/v1/offer/{id}/dishes', 'restful\OfferController');
Route::controller('api/v1/offer/{id}/choice/multiple', 'restful\OfferController');
Route::controller('api/v1/offer/{id}/choice/any', 'restful\OfferController');

// These works fine to me
'api/v1/offer/{id?}'           -> properly routes to OfferController::getIndex
'api/v1/offer/{id}/qualifiers' -> properly routes to OfferController::getQualifiers
'api/v1/offer/{id}/dishes'     -> properly routes to OfferController::getDishes

// ... but here i have problems.
'api/v1/offer/{id}/choice/multiple' -> routes to OfferController::choice
'api/v1/offer/{id}/choice/any'      -> routes to OfferController::choice

Why do in last 2 cases request is not routed to multiple/any method? How's the router logic in this case?

1 Answer 1

2

I think you have two options here.

First one, is specifying your controller actions in your routes. Note that I'm using Route::get() and @action:

Route::get('api/v1/offer/{id}/choice/multiple', 'restful\OfferController@multiple');
Route::get('api/v1/offer/{id}/choice/any', 'restful\OfferController@any');

Second, let Laravel to wire any api/v1/offer/{id}/choice to OfferController:

Route::controller('api/v1/offer/{id}/choice', 'restful\OfferController');

If you use this second option, you have to define your actions like this in your controller (assuming they are GET requests):

class OfferController extends BaseController {

    public function getMultiple()
    {
        //
    }

    public function getAny()
    {
        //
    }


}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.