/** * * * @param string $id * @return mixed */ public function actionSort() { $gallery = Gallery::findOne(Yii::$app->session->get('gallery.gallery-id')); $images = Image::find()->where(['itemId' => $gallery->id, 'modelName' => 'Gallery'])->orderBy(['position' => SORT_DESC])->all(); return $this->render('sort', ['gallery' => $gallery, 'images' => $images]); }
/** * Finds the Gallery model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Gallery the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Gallery::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }