public function actionDelete($id, $type = null) { // Find Model $model = PermissionService::findById($id); // Delete/Render if exist if (isset($model)) { $model->type = $type; if ($model->load(Yii::$app->request->post(), 'Permission')) { if (PermissionService::delete($model)) { $this->redirect($this->returnUrl); } } $roles = RoleService::getIdNameListByType($type); return $this->render('delete', ['model' => $model, 'roles' => $roles]); } // Model not found throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND)); }