Yii paramater on controller action

I have this before action inside my controller

public function beforeAction($action)
{            
	if ($action->id == 'delete-property') {
        $this->enableCsrfValidation = false;
    }
}

and this is the controller action

   //Property Delete ID
   public function actionDeleteProperty($id)
    {
	  $id = Yii::$app->request->get('id');
	  echo $id;
	}

This is the url manager

 'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
			'<controller:[\w\-]+>/<action:[\w\-]+>/<id:[\d]+>' => '<controller>/<action>'
        ],
    ],

When i visit http://localhost/hotel/delete-property/60d75e5842777110b81711b3 i get 404

How do i fix this?

just try to remove param $id

Perhaps [0-9a-f]+ instead of \d+

1 Like