Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!$this->isShow()) {
         return false;
     }
     $place = Place::find()->published()->andWhere(["code" => $this->code])->one();
     if ($place) {
         $models = $place->getBanners()->published()->all();
         if (empty($models)) {
             return false;
         }
         $i = rand(0, count($models) - 1);
         $this->model = $models[$i];
     }
 }
Beispiel #2
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!$this->isShow()) {
         return false;
     }
     $place = Place::find()->published()->andWhere(["code" => $this->code])->one();
     if ($place) {
         $this->models = $place->getBanners()->published()->orderBy(["sort" => SORT_ASC])->all();
         foreach ($this->models as $k => $banner) {
             if (!$banner->isSuitable()) {
                 unset($this->models[$k]);
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Возвращает массив для привязкт к баннерным местам
  * @return array
  */
 public function getPlaces()
 {
     $models = Place::find()->published()->orderBy(["title" => SORT_ASC])->all();
     return ArrayHelper::map($models, "id", "title");
 }