0

How can I defined two same URI that have two difference method to be called ? For example :

 'owners/<user_id:\d+>/pets' => 'pets/index', //using GET
 'owners/<user_id:\d+>/pets' => 'pets/create',//using POST

I try this code below :

 'GET owners/<user_id:\d+>/pets' => 'pets/index',
 'POST owners/<user_id:\d+>/pets' => 'pets/create',

but my problem is that if I have this code It always display 404 not found instead of 405?

Note that I already added this on my behaviors :

'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'index'  => ['get'],
                    'create'  => ['post'],
                ],
            ],
bumbumpaw
  • 2,522
  • 1
  • 24
  • 54

1 Answers1

0

I would try this (in this order):

'POST owners/<user_id:\d+>/pets' => 'pets/create',
'owners/<user_id:\d+>/pets' => 'pets/index',
gmc
  • 3,910
  • 2
  • 31
  • 44