@param $id

@return string|\yii\web\Response
@throws NotFoundHttpException
@throws \yii\db\Exception
776611
public function actionUpdate($id)
    {
        if (request()->post('_asnew') == '1') {
            $model = new Comment();
        }else{
            $model = $this->findModel($id);
        }

        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,
        ]);

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

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

        $this->assertSuccessResponse($response);

        return $response->getData();
    }
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;
    }
331458
protected function findModel($id)
    {
        $item = Yii::$app->authManager->getRule($id);
        if ($item) {
            return new AdminBizRule($item);
        } else {
            throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
        }
    }
171542
public function actionView($id)
    {
        $user = $this->findModel(Yii::$app->user->id);
        /** @var DatabaseNotification $notification */
        if (($notification = $user->getNotifications()->andWhere(['id' => $id])->one()) != null) {
            $notification->setRead();
            return $notification;
        } else {
            throw new NotFoundHttpException("Notification not found: $id");
        }
    }
683280
public function load($id)
    {
        $row = $this->gateway->loadUrlWildcardData($id);

        if (empty($row)) {
            throw new NotFoundException('UrlWildcard', $id);
        }

        return $this->mapper->extractUrlWildcardFromRow($row);
    }
902798
public function actionView($id)
    {
        $model = $this->findModel($id);
        $viewPostUrl = $this->getViewPostUrl($model);

        return $this->render('view', [
            'model' => $model,
            'viewPostUrl' => $viewPostUrl,
        ]);
    }
568807
public function actionUpdate($id)
    {
        $this->layout = static::FORM_LAYOUT;
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            $this->afterUpdate($model);

            if ($this->hasView) {
                return $this->redirect(['view', 'id' => $model->id]);
            } else {
                return $this->redirect(['index']);
            }
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
608662
protected function getSite($id)
    {
        $site = $this->siteManager->findOneBy(['id' => $id]);

        if (null === $site) {
            throw new NotFoundHttpException(sprintf('Site (%d) not found', $id));
        }

        return $site;
    }
307397
protected function findModel($id)
    {
        $query = Fans::find()
            ->andWhere([
                'id' => $id,
                'wid' => $this->getWechat()->id
            ]);
        if (($model = $query->one()) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
418557
protected function findModel($id)
    {
        $user = User::findOne($id);
        if ($user === null) {
            throw new NotFoundHttpException('The requested page does not exist');
        }
        return $user;
    }
331665
protected function findModel($id)
    {
        if (($model = Term::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
        }
    }
1274014
public function actionView($id)
    {
        try{

            $request = \Yii::$app->request;
            if ($request->getIsOptions()) {
                return $this->ResponseOptions($this->verbs()['view']);
            }
            $model = $this->findModel($id);
            if($model!=null){
                $result= ['success'=>true,'rules'=>$model];
            } else {
                $result= ['success'=>false,'message'=>'没有对应规则'];
            }

            return $result;
        }catch(Exception $e){
            throw new Exception($e);
        }
        //return $this->render('view', ['model' => $model]);
    }
559386
public function run($id)
    {
        if (Yii::$app->request->isAjax) {
            Yii::$app->response->format = Response::FORMAT_JSON;

            $model = $this->findModel($id);

            if (Yii::$app->request->isPost) {
                $post = Yii::$app->request->post();
                $parentId = isset($post['parent_id']) ? $post['parent_id'] : 0;
                $prevId = isset($post['prev_id']) ? $post['prev_id'] : 0;
                $nextId = isset($post['next_id']) ? $post['next_id'] : 0;

                try {
                    if (empty($parentId)) {
                        if ($this->isMultipleTree) {    ///[isMultipleTree]
                            if (!$model->isRoot()) {
                                $result = $model->makeRoot();
                            }

                            ///?????root sorting logic

                        } else {
                            return [
                                'status' => 'error',
                                'error' => 'Tree root operations are protected when "isMultipleTree" is false!',
                            ];
                        }
                    } elseif (!empty($prevId)) {
                        $prevModel = $this->findModel($prevId);
                        $result = $model->insertAfter($prevModel);
                    } elseif (!empty($nextId)) {
                        $nextModel = $this->findModel($nextId);
                        $result = $model->insertBefore($nextModel);
                    } else {
                        $parentModel = $this->findModel($parentId);
                        $result = $model->appendTo($parentModel);
                    }
                } catch (\Exception $e) {
                    return [
                        'status' => 'error',
                        'error' => $e->getMessage(),
                    ];
                }

                ///Note: remove `save()` when using `creocoder/yii2-nested-sets`!
                return is_bool($result) ? $result : $result->save();
            }
        }

        ///Redirect to this controller's default action
        return $this->controller->redirect([$this->controller->defaultAction]);
    }
1351711
protected function findModel($id)
    {
        if (($model = Contact::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException(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.'));
        }
    }
1013434
public function findModel($id)
    {
        if (($model = Category::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException (Yii::t('system', 'The requested page does not exist.'));
        }
    }