コード例 #1
0
 /**
  * Get all bannerModels
  * @return array of \common\models\Banner
  */
 public static function getBannerModels()
 {
     if (count(self::$banners) > 0) {
         return self::$banners;
     }
     $banners = Banner::find()->orderBy(['weight' => SORT_DESC])->all();
     self::$banners = $banners;
     return self::$banners;
 }
コード例 #2
0
ファイル: BannerSearch.php プロジェクト: kotmonstr/kotmonstr
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Banner::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
コード例 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Banner::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'description', $this->description], ['like', 'title', $this->title]);
     return $dataProvider;
 }
コード例 #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Banner::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'size' => $this->size, 'region' => $this->region, 'weight' => $this->weight, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
コード例 #5
0
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     //Banner
     $banner_mod = \common\models\Banner::find()->where(['status' => \common\enum\BannerStatus::ACTIVE])->orderBy(['sequence' => SORT_ASC])->all();
     if ($banner_mod) {
         foreach ($banner_mod as $rec) {
             $banner[] = ['title' => $rec->title, 'image' => $rec->image ? \Yii::$app->params['pathBannerImage'] . $rec->image : '', 'description' => $rec->description];
         }
     } else {
         $banner[] = ['title' => 'Fafediesel Group', 'image' => \Yii::$app->params['pathBannerImage'] . 'rectangle1.png', 'description' => 'Um parceiro ao seu serviço.'];
     }
     //News - Widget
     $model = \common\models\News::find()->where(['status' => \common\enum\NewsStatus::ACTIVE])->orderBy(['date' => SORT_DESC])->all();
     if ($model) {
         foreach ($model as $rec) {
             $news[] = ['title' => $rec->title, 'logo' => $rec->logo ? \common\models\News::$default_data_location . '/icon/' . $rec->logo : '', 'intro' => $rec->intro, 'link' => '/news/view/#' . $rec->id, 'date' => $rec->date];
         }
     } else {
         $news[] = ['title' => 'sem notícias no momento', 'logo' => '', 'intro' => '', 'link' => '', 'date' => ''];
     }
     $this->layout = 'main_plain';
     return $this->render('index', ['banner' => $banner, 'news' => $news]);
 }
コード例 #6
0
 public function actionChangeActivety()
 {
     $arrResult = [];
     $id = Yii::$app->request->post('id');
     $state = Yii::$app->request->post('state');
     //vd( $id .': ' .$state );
     if ($state == 'true') {
         $status = 0;
     } else {
         $status = 1;
     }
     if ($id) {
         $model = Banner::find()->where(['id' => $id])->one();
         $model->status = $status;
         $model->updateAttributes(['status']);
     }
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $arrResult['state'] = $status;
     $arrResult['id'] = $id;
     return $arrResult;
 }
コード例 #7
0
 public function actionBlogDetail($id)
 {
     $data = $this->getCommonDate();
     $modelGoodsCategories = GoodsCategory::find()->all();
     $modelBanner = Banner::find()->where(['status' => 0])->all();
     $modelBrends = Brend::find()->all();
     $modelBlog = Blog::findOne($id);
     $modelBlogComents = BlogComments::getComentsByBlogId($id);
     return $this->render('blog-detail', ['modelBlog' => $modelBlog, 'data' => $data, 'modelGoodsCategories' => $modelGoodsCategories, 'modelBrends' => $modelBrends, 'modelBanner' => $modelBanner, 'modelBlogComents' => $modelBlogComents]);
 }