public function findModel($id = false, $search = false)
    {
        $model = Module::getModel(
            $this,
            ($search ? $this->searchModelName : $this->modelName),
            ['controllers' => 'models'],
            ['scenario' => $this->getScenario()]
        );
        if ($id && (!$model = $model->search(compact('id'))->one())) {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
        $model->scenario = $this->getScenario(); // for found model too
        return $model;
    }
public function findModel($id = false, $search = false)
    {
        $model = Module::getModel(
            $this,
            ($search ? $this->searchModelName : $this->modelName),
            ['controllers' => 'models'],
            ['scenario' => $this->getScenario()]
        );
        if ($id && (!$model = $model->search(compact('id'))->one())) {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
        $model->scenario = $this->getScenario(); // for found model too
        return $model;
    }
public function findModel ( $ id = false , $ search = false ) { $ model = Module :: getModel ( $ this , ( $ search ? $ this -> searchModelName : $ this -> modelName ) , [ 'controllers' => 'models' ] , [ 'scenario' => $ this -> getScenario ( ) ] ) ; if ( $ id && ( ! $ model = $ model -> search ( compact ( 'id' ) ) -> one ( ) ) ) { throw new NotFoundHttpException ( 'The requested page does not exist.' ) ; } $ model -> scenario = $ this -> getScenario ( ) ; // for found model too return $ model ; }
Finds the Item model based on its primary key value.
If the model is not found, a 404 HTTP exception will be thrown.
@param integer|boolean $id
@param boolean $search
@return Item|ItemSearch the loaded model
@throws NotFoundHttpException if the model cannot be found
Finds the Item model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .