Yii Framework Forum: REST Url Manager - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

REST Url Manager URL Rules

#1 User is offline   dannythebestguy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 27-June 12

Posted 16 June 2017 - 09:05 AM

Can somebody show what should I do to add the additional employees parameters to the company Activecontroller.

/companies/3/employees/45

I have a company controller, with byEmployee($employeeID) action.

I want to extract the details of employee 45 working in company 3.

Which I can easily do in regular controller with :

http:://localhost/frontend/web/index.php?r=company/byEmployee&cid=3&eid=45
0

#2 User is offline   alrazi 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,289
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 16 June 2017 - 02:36 PM

you need to enable the urlManager and add rule for that route

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '<companies:[\w+]>/<companyid:[\d+]>/<employees:[\w+]>/<employeeid: [\d+]>' => '<controllerName>/<actionName>'
            ],
        ],

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users