コード例 #1
0
ファイル: AdsSearch.php プロジェクト: Sywooch/AVSProduct
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Ads::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'type_id' => $this->type_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'banner_path', $this->banner_path])->andFilterWhere(['like', 'banner_base_url', $this->banner_base_url])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: AdsViews.php プロジェクト: Sywooch/AVSProduct
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAds()
 {
     return $this->hasOne(Ads::className(), ['id' => 'ads_id']);
 }
コード例 #3
0
ファイル: Ads.php プロジェクト: Sywooch/AVSProduct
 public function getEvent()
 {
     return $this->hasMany(Ads::className(), ['ads_id' => 'id']);
 }
コード例 #4
0
ファイル: Adstype.php プロジェクト: Sywooch/AVSProduct
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAds()
 {
     return $this->hasMany(Ads::className(), ['type_id' => 'id']);
 }
コード例 #5
0
ファイル: AdsController.php プロジェクト: Sywooch/AVSProduct
 /**
  * Finds the Ads model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Ads the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Ads::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #6
0
ファイル: BlockCode.php プロジェクト: Sywooch/AVSProduct
 /**
  * Возвращает актуальное объявление
  * @param $hash_block
  * @param $host
  * @return array advertisment
  */
 public function getImgUrl($hash_block, $host)
 {
     $block_code = BlockCode::find()->where(['hash_block' => $hash_block])->one();
     $param['blockcode_id'] = $block_code['id'];
     $param['platform_id'] = $block_code['platform_id'];
     $param['type_id'] = $block_code['adstype_id'];
     $platform = Platforms::find()->where(['id' => $param['platform_id'], 'status' => Platforms::STATUS_ACTIVE])->one();
     if (!empty($platform)) {
         if ($this->getHost($platform['url']) != $this->getHost($host)) {
             return array('name' => 'Exception403');
         }
     }
     $categories_id = CodeblocksAdscategories::find()->where(['blockcode_id' => $param['blockcode_id']])->all();
     if (is_array($categories_id)) {
         foreach ($categories_id as $category_id) {
             $categories[] = $category_id['adscategory_id'];
         }
     }
     $ads = Ads::find()->where(['status' => Ads::STATUS_ACTIVE, 'type_id' => $param['type_id'], 'category_id' => $categories])->all();
     foreach ($ads as $advertisement) {
         $views = $advertisement->getView()->all();
         $sortAds[$advertisement->id] = count($views);
         $ads_type = $advertisement->getAdsType()->One();
         $adsArray[$advertisement->id]['picture'] = $advertisement->picture;
         $adsArray[$advertisement->id]['id'] = $advertisement->id;
         $adsArray[$advertisement->id]['action_url'] = $advertisement->action_url;
         $adsArray[$advertisement->id]['height'] = $ads_type->height;
         $adsArray[$advertisement->id]['width'] = $ads_type->width;
     }
     asort($sortAds);
     $currentAds = key($sortAds);
     //        $adsView = new AdsViews();
     //        $adsView->actionView($currentAds,$param['platform_id']);
     return $adsArray[$currentAds];
 }