Пример #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMultimedia()
 {
     return $this->hasMany(Multimedia::className(), ['objetos_id' => 'id']);
 }
 /**
  * Finds the Multimedia model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @param integer $tipoMultimedia_id
  * @return Multimedia the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Multimedia::findOne(['id' => $id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionUpdateIngreso($id)
 {
     // Return
     if (Yii::$app->request->post('saveClose') == 2) {
         $model = $this->findModel($id);
         $dataprovider = new ArrayDataProvider(['allModels' => Multimedia::findAll(['objetos_id' => $model->id])]);
         //Obtener Ubicaciones Externas
         $dataprovider_ue = new ArrayDataProvider(['allModels' => UbicacionExterna::findAll(['acervo_id' => $model->id])->orderBy('fechaInicio DESC')]);
         return $this->redirect(['ingreso/update', 'id' => $model->ingreso_id, 'dataprovider' => $dataprovider, 'dataProviderUbicacionExterna' => $dataprovider_ue]);
     }
     return $this->createOrUpdate($id, NULL, TRUE);
 }
Пример #4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $response = [];
     $data = Request::all();
     $update = [];
     if (isset($data['tab'])) {
         if ($data['tab'] == "festival") {
             $fest = Festival::find($id);
             $fest->name = $data['name'];
             $fest->start_datetime = date("Y-m-d H:i:s", strtotime($data['start_datetime']));
             $fest->end_datetime = date("Y-m-d H:i:s", strtotime($data['end_datetime']));
             $fest->city = isset($data['city']) ? trim(explode(',', $data['city'])[0]) : "";
             $fest->country_id = isset($data['city']) ? BackendController::getCountryID(trim(last(explode(',', $data['city'])))) : "";
             $fest->venue = isset($data['venue']) ? $data['venue'] : "";
             $fest->description = isset($data['description']) ? $data['description'] : "";
             $fest->link = isset($data['link']) ? $data['link'] : "";
             $fest->facebook = isset($data['facebook']) ? $data['facebook'] : "";
             $fest->twitter = isset($data['twitter']) ? $data['twitter'] : "";
             $fest->budget = isset($data['budget']) ? $data['budget'] : "";
             if ($fest->save()) {
                 $statusCode = 200;
             } else {
                 $statusCode = 422;
             }
             return Response::json($fest, $statusCode);
         }
         if ($data['tab'] == "organizer") {
             $fest = Festival::find($id);
             $fest->Association()->detach();
             foreach ($data['organizers'] as $org) {
                 $fest->Association()->attach($org);
             }
             return Response::json($fest, "200");
         }
         if ($data['tab'] == "person") {
             $fest = Festival::find($id);
             $fest->Person()->detach();
             foreach ($data['person'] as $per) {
                 $fest->Person()->attach($per);
             }
             return Response::json($fest, "200");
         }
         if ($data['tab'] == "guest") {
             $fest = Festival::find($id);
             $fest->Guest()->detach();
             foreach ($data['guests'] as $guest) {
                 $fest->Guest()->attach($guest);
             }
             return Response::json($fest, "200");
         }
         if ($data['tab'] == "performer") {
             $fest = Festival::find($id);
             $fest->Performer()->detach();
             foreach ($data['performer'] as $perf) {
                 $fest->Performer()->attach($perf);
             }
             return Response::json($fest, "200");
         }
         if ($data['tab'] == "multimedia") {
             if ($data['old_poster'] !== $data['poster']) {
                 $mm = \App\Models\Multimedia::find($data['old_poster']);
                 $mm->poster = "0";
                 $mm->save();
                 $mm = \App\Models\Multimedia::find($data['poster']);
                 $mm->poster = "1";
                 $mm->save();
             }
             if ($data['old_cover'] !== $data['cover']) {
                 $mm = \App\Models\Multimedia::find($data['old_cover']);
                 $mm->poster = "0";
                 $mm->save();
                 $mm = \App\Models\Multimedia::find($data['cover']);
                 $mm->poster = "2";
                 $mm->save();
             }
             $response = ['result' => "success"];
             return Response::json($response, "200");
         }
     }
     //return Response::json($response, $statusCode);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $m = Multimedia::find($id)->delete();
     $response = [];
     $response["filename"] = $m['filename'];
     $statusCode = 200;
     return Response::json($response, $statusCode);
 }