예제 #1
0
 /**
  * Ищет рекламный блок по его номеру и возвращает код для втавки на страницу
  *
  * @return string
  */
 public function run()
 {
     /** @var Advert $advert */
     if (!$this->block_number) {
         return '';
     }
     $advert = Advert::findOne(['block_number' => $this->block_number]);
     return $advert ? $advert->code : '';
 }
예제 #2
0
 /**
  * Finds the Advert model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Advert the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Advert::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }