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