@param $id

@return \yii\web\Response
@throws NotFoundHttpException
@throws \yii\db\Exception
170050
public function actionDelete($id)
    {
        $model = $this->findModel($id);
        if ($model->deleteWithRelated()) {
            set_flash_success_delete_content();
            Seo::deleteAll([
                'obj_type' => $model->name,
            ]);
            TermRelationships::deleteAll([
                'obj_type' => $model->name,
            ]);
        } else {
            set_flash_error_delete_content();
        }

        return $this->goBack(request()->referrer);
    }
1296140
public function get($id)
    {
        $request = new Request('customizations');
        $request->setIdParam(urlencode($id));

        $response = $this->client->get($request);

        $this->assertSuccessResponse($response);

        return $response->getData();
    }
993813
public function actionRevoke($id)
    {
        $items = Yii::$app->getRequest()->post('items', []);
        $model = new AdminAssignment($id);
        $success = $model->revoke($items);
        Yii::$app->getResponse()->format = Response::FORMAT_JSON;
        return array_merge($model->getItems(), ['success' => $success]);
    }
1059639
public function actionCustomUpdate($id = '')
    {
        $model = Options::findOne(['id' => $id]);
        if (yii::$app->getRequest()->getIsPost()) {
            if ($model->load(yii::$app->getRequest()->post()) && $model->save()) {
                yii::$app->getSession()->setFlash('success', yii::t('cms', 'Success'));
                return $this->redirect(['custom']);
            } else {
                $errors = $model->getErrors();
                $err = '';
                foreach ($errors as $v) {
                    $err .= $v[0] . '<br>';
                }
                yii::$app->getResponse()->format = Response::FORMAT_JSON;
                return [
                    'err_msg' => $err,
                ];
            }
        } else {
            yii::$app->getResponse()->format = Response::FORMAT_HTML;
            echo '<div class="" id="editForm">';
            echo '<div class="ibox-content">';
            $form = ActiveForm::begin(['options' => ['name' => 'edit']]);
            echo $form->field($model, 'name')->textInput();
            echo $form->field($model, 'input_type')->dropDownList(Constants::getInputTypeItems());
            echo $form->field($model, 'tips')->textInput();
            echo $form->field($model, 'autoload')->dropDownList(Constants::getYesNoItems());
            echo $form->field($model, 'value')->textInput();
            echo $form->field($model, 'sort')->textInput();
            echo $form->defaultButtons();
            ActiveForm::end();
            echo '</div>';
            echo '</div>';
        }
    }
461656
public function find($id)
    {
        try
        {
            $model = $this->model->findOrFail($id);
        }
        catch(ModelNotFoundException $e)
        {
            throw new NotFoundException;
        }

        return $model;
    }
1102405
public function actionTaskUpdate($id)
    {
        $model = Project::getTaskModel($id);
        if (!isset($model)) {
            throw new NotFoundHttpException('The Task "' . $id . '" not found.');
        }
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['taskview', 'id' => $model->id,]);
        } else {
            return $this->render('taskupdate', [
                'model' => $model,
            ]);
        }
    }
280885
public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        $model->setScenario('update');
        if($model->load(Yii::$app->request->post())){
            if($model->password){
                $model->setPassword($model->password);
                $model->generateAuthKey();
            }

            if ($model->save()) {
                //MenuHelper::invalidate();
                return $this->redirect(['index']);
            } else {
                return $this->render('update', [
                    'model' => $model,
                ]);
            }
        }else{
            return $this->render('update', [
                'model' => $model,
            ]);
        }


    }
691741
public function actionUpdate($id)
    {
        $request = \Yii::$app->request;
        if ($request->getIsOptions()) {
            return $this->ResponseOptions($this->verbs()['update']);
        }
        try{
            $model = $this->findModel($id);
            if ($model->menuParent) {
                $model->parent_name = $model->menuParent->name;
            }
            if ($model->load(Yii::$app->request->post()) && $model->save()) {
                Helper::invalidate();
                return ["success"=> true];
            } else {
                return ["success"=> false];
            }
        }catch(Exception $e){
            throw new Exception($e);
        }
    }
560384
protected function findModel($id)
    {
        $item = Yii::$app->getAuthManager()->getRole($id);
        if ($item) {
            return new AuthItem($item);
        } else {
            throw new NotFoundHttpException(\Yii::t('app', 'The requested page does not exist.'));
        }
    }
1122419
protected function findModel($id)
    {
        /* @var $module Module */
        $module = Yii::$app->getModule(Module::$name);
        $commentModelData = $module->model('comment');
        /** @var CommentModel $commentModel */
        $commentModel = Yii::createObject($commentModelData);
        if (($model = $commentModel::findOne($id)) !== NULL) {
            return $model;
        } else {
            throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
        }
    }
1075989
public function findModel($id)
    {
        $model = $this->findModelClassObject($this->modelClass, $id, 'view');
        
        if (!$model) {
            throw new NotFoundHttpException("Unable to find the Model for the given ID");
        }
        
        return $model;
    }
44731
protected function findModel($id)
    {
        $item = Yii::$app->authManager->getRule($id);
        if ($item) {
            return new BizRule($item);
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
1207017
public function actionView($id)
    {
        $model = $this->findModel($id);
        $providerBlock = new \yii\data\ArrayDataProvider([
            'allModels' => $model->blocks,
        ]);
        $providerComment = new \yii\data\ArrayDataProvider([
            'allModels' => $model->comments,
        ]);
        $providerPost = new \yii\data\ArrayDataProvider([
            'allModels' => $model->posts,
        ]);
        $providerProduct = new \yii\data\ArrayDataProvider([
            'allModels' => $model->products,
        ]);
        $providerTerm = new \yii\data\ArrayDataProvider([
            'allModels' => $model->terms,
        ]);
        return $this->render('view', [
            'model' => $this->findModel($id),
            'providerBlock' => $providerBlock,
            'providerComment' => $providerComment,
            'providerPost' => $providerPost,
            'providerProduct' => $providerProduct,
            'providerTerm' => $providerTerm,
        ]);
    }
393473
public function actionUpdate($id)
    {
        if (request()->post('_asnew') == '1') {
            $model = new User();
        }else{
            $model = $this->findModel($id);
        }

        if (!is_role('admin')) {
            throw new \yii\web\HttpException(403, t('app', 'You are not allowed to perform this action.'));
        }

        if ($model->loadAll(request()->post())) {
            if ($model->saveAll()) {
                set_flash_has_been_saved();
                return $this->redirect(['update', 'id' => $model->id]);
            } else {
                set_flash_has_not_been_saved();
            }
        }

        return $this->render('update', [
            'model' => $model,
        ]);
    }
1219724
public function findOrFail(int $id)
    {
        $response = $this->model->with($this->with)->findOrFail($id);
        $this->with = [];
        return $response;
    }
1285454
public function actionCreate($id)
    {
        $model = new Item();
        $model->pid = $id;
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->session->setFlash('success', Yii::t('modules/page', 'Success'));
            return $this->redirect(['update', 'id' => $model->id]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
116006
public function run($id)
    {
        /* @var $model \yii\db\ActiveRecord */
        $model = call_user_func([$this->modelClass, 'findOne'], $id);
        return $this->controller->render('view', [
            'model' => $model,
        ]);
    }