Beispiel #1
0
 public function run()
 {
     if ($this->id === null) {
         $slides = Slide::find()->where(['status' => Slide::STATUS_ENABLED])->all();
     } else {
         $slides = Slide::find()->where(['id' => $this->id, 'status' => Slide::STATUS_ENABLED])->limit(1)->all();
     }
     return $this->render('slide', ['slides' => $slides]);
 }
 public function actionIndex()
 {
     // slide small 1
     $slideCruises = Slide::find()->where(['position' => 2])->all();
     // slide small 2
     $slideLately = Slide::find()->where(['position' => 3])->all();
     // tour hot cruises
     $tourHotCruises = Tour::find()->where(['hot' => 1])->all();
     // tour hot lately
     $tourHotLately = Tour::find()->where(['hot' => 2])->all();
     return $this->render('index', ['slideCruises' => $slideCruises, 'slideLately' => $slideLately, 'tourHotCruises' => $tourHotCruises, 'tourHotLately' => $tourHotLately]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Slide::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, 'position' => $this->position]);
     $query->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'link', $this->link]);
     return $dataProvider;
 }
Beispiel #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Slide::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, 'common_status_id' => $this->common_status_id]);
     $query->andFilterWhere(['like', 'source_url', $this->source_url])->andFilterWhere(['like', 'alt', $this->alt]);
     return $dataProvider;
 }
Beispiel #5
0
 /**
  * Returns corresponding slides with cache support(not real relation!)
  * @return Slide[]
  */
 public function getSlides($onlyActive = false)
 {
     if ($this->_slides === null) {
         $this->_slides = Yii::$app->cache->get("Slides:" . $this->id);
         if (!is_array($this->_slides)) {
             $this->_slides = Slide::find()->where(['slider_id' => $this->id])->orderBy('sort_order ASC')->all();
             Yii::$app->cache->set("Slides:" . $this->id, $this->_slides, 86400, new \yii\caching\TagDependency(['tags' => [ActiveRecordHelper::getObjectTag(Slide::className(), $this->id)]]));
         }
     }
     if ($onlyActive === true) {
         $activeSlides = [];
         foreach ($this->_slides as $slide) {
             if ($slide->active) {
                 $activeSlides[] = $slide;
             }
         }
         return $activeSlides;
     } else {
         return $this->_slides;
     }
 }
Beispiel #6
0
 public function postUpdate(Request $request)
 {
     $id = $request->input('id');
     $name = $request->input('name');
     $alt = $request->input('alt');
     $image = $request->input('images');
     $data = '';
     try {
         if (isset($name) && !empty($name)) {
             $table = Slide::find($id);
             $table->name = $name;
             $table->update_time = date("Y-m-d H:i:s");
             $table->images = $image;
             $table->alt = $alt;
             $rs = $table->save();
             $data = ['id' => $id, 'name' => $name, 'update_time' => date("Y-m-d H:i:s"), 'images' => $image, 'alt' => $alt];
             $this->message = 'Cập nhật thành công';
         } else {
             $this->error = true;
             $this->error_message = 'Vui lòng nhập đầy đủ thông tin';
             goto next;
         }
     } catch (Exception $e) {
         $this->error = true;
         $this->error_message = $e->getMessage();
         goto next;
     }
     next:
     return $this->ResponseData($data);
 }
Beispiel #7
0
/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use app\models\Infocompany;
use app\models\Slide;
use app\models\Article;
use yii\widgets\ActiveForm;
AppAsset::register($this);
/* select info company */
$info = Infocompany::find()->one();
/* select slide */
$slides = Slide::find()->where(['position' => '1'])->all();
/* select article*/
$article = Article::find()->where(['hot' => '1'])->all();
/* select article services */
$articleService = Article::find()->where(['type' => "100"])->all();
$services = [];
for ($i = 0; $i < count($articleService); $i++) {
    $services[] = ['label' => $articleService[$i]->title, 'url' => ['article/' . implode('-', explode(' ', $articleService[$i]->title))]];
}
$this->title = $info->name;
$hotelInfo = \app\models\Location::find()->all();
$hotelMenu = [];
for ($i = 0; $i < count($hotelInfo); $i++) {
    $item = [];
    $item['label'] = 'Hotels in ' . $hotelInfo[$i]->name;
    $hotelName = implode('-', explode(" ", $hotelInfo[$i]->name));
Beispiel #8
0
 public function actionList()
 {
     $dataProvider = new ActiveDataProvider(['query' => Slide::find()]);
     return $this->render('list', ['dataProvider' => $dataProvider]);
 }
Beispiel #9
0
 public function actionGallery()
 {
     $models = Slide::find()->active()->all();
     return $this->render('gallery', ['models' => $models]);
 }