Esempio n. 1
0
 public static function getData()
 {
     $rows = Promocion::find()->all();
     $arrayData = array();
     foreach ($rows as $row) {
         $row->imagenes = Promocion::getPromImagesById($row->id);
         $arrayData[$row->id] = $row->attributes + ['imagenes' => $row->imagenes];
     }
     $jsonData = Json::encode($arrayData);
     return $jsonData;
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Promocion::find();
     $query->joinWith(['menu', 'sucursal']);
     $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, 'id_menu' => $this->id_menu, 'id_sucursal' => $this->id_sucursal, 'precio' => $this->precio, 'dia' => $this->dia, 'fecha_ini' => $this->fecha_ini, 'fecha_fin' => $this->fecha_fin, 'create_user' => $this->create_user, 'create_time' => $this->create_time, 'update_user' => $this->update_user, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'descripcion', $this->descripcion])->andFilterWhere(['like', 'menu.nombre', $this->menu])->andFilterWhere(['like', 'sucursal.nombre', $this->sucursal]);
     return $dataProvider;
 }
 /**
  * Finds the Promocion model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Promocion the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Promocion::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPromocions()
 {
     return $this->hasMany(Promocion::className(), ['id_sucursal' => 'id']);
 }