public function actionView($id) { $model = tblGallery::findOne($id); if ($model->load($_POST)) { $files = \yii\web\UploadedFile::getInstances($model, 'upload_files'); if (isset($files) && count($files) > 0) { $mPath = \Yii::getAlias('@webroot') . '/images/gallery/cat_' . $id; if (!is_dir($mPath)) { mkdir($mPath); chmod($mPath, '777'); } foreach ($files as $file) { $mPic = substr(number_format(time() * rand(), 0, '', ''), 0, 14) . '.' . $file->extension; //Upload Images if ($file->saveAs($mPath . '/' . $mPic)) { $image = \Yii::$app->image->load($mPath . '/' . $mPic); $image->resize(1024, 1024); $image->save($mPath . '/' . $mPic); //resize images thumb $image = \Yii::$app->image->load($mPath . '/' . $mPic); $image->resize(250, 250); $mThumb = $mPath . '/thumb/'; if (!is_dir($mThumb)) { mkdir($mThumb); chmod($mThumb, '777'); } $image->save($mThumb . $mPic); } } } } return $this->render('view', ['model' => $model]); }
public function actionView($id) { $counter = new counter(); $counter->hitsCounter('gallery/view', $id); $model = tblGallery::findOne($id); $gallery = new tblGallery(); return $this->render('view', ['model' => $model, 'gallery' => $gallery]); }
public function lists($limit = '3') { $search = $this->search; //($_POST['Article']['search'])? $_POST['Article']['search']:($_REQUEST['search'])? $_REQUEST['search']:''; $langs = $this->langs; $query = tblGallery::find()->where('title LIKE :s', [':s' => "%{$search}%"]); if ($langs) { $query->andWhere(['langs' => $langs]); } $query->orderBy('id DESC'); $query->limit($limit); $result = $query->all(); return $result; }
public function lists($amphur = null, $limit = '3') { $search = $this->search; $langs = $this->langs; //$amphur = $this->amphur; $query = tblGallery::find()->where('title LIKE :s', [':s' => "%{$search}%"]); if ($langs) { $query->andWhere(['langs' => $langs]); } if ($amphur) { $query->andWhere(['amphur' => $amphur]); } $query->orderBy('id DESC'); $query->limit($limit); $result = $query->all(); return $result; }