Exemplo n.º 1
0
 /**
  * Finds the Slider model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Slider the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Slider::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 2
0
 public function run()
 {
     if (!$this->id) {
         throw new Exception('Slider ID is missing');
     }
     $slider = Slider::findOne($this->slider_id);
     if ($slider) {
         $slides = Slide::find()->active()->where(['slider_id' => $this->slider_id])->language()->order()->all();
         if (!empty($slides)) {
             return $this->render('Slider', ['id' => $this->id, 'sectionClass' => $this->sectionClass, 'slides' => $slides]);
         } else {
             return '';
         }
     }
     return '';
 }