예제 #1
0
 public function loadModel($id)
 {
     $model = \app\models\Banner::findOne($id);
     if ($model === null) {
         throw new \yii\web\HttpException(404, 'Запрашиваемая страница не существует.');
     }
     return $model;
 }
예제 #2
0
 public function uniquedName($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $banner = Banner::findOne(['name' => $this->name]);
         if ($banner) {
             $this->addError($attribute, '该导航名已存在');
         }
     }
 }
예제 #3
0
 /**
  * Finds the Banner model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Banner the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Banner::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }