Ejemplo n.º 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $place = Place::find($id->id);
     $cuisineIDs = $place->cuisine->pluck('id', 'cuisinename');
     $cuisines = Cuisine::all();
     return view("location._edit", compact('place', 'cuisines', 'cuisineIDs'));
 }
Ejemplo n.º 2
0
 public function edit()
 {
     $place = Place::find($this->request->id);
     if (!$place) {
         $this->redirect('Places::index');
     }
     if ($this->request->data && $place->save($this->request->data)) {
         $this->redirect(array('Places::view', 'args' => array($place->id)));
     }
     return compact('place');
 }
Ejemplo n.º 3
0
 public function getPhotoByPlace($id_place)
 {
     $place = Place::find($id_place);
     if ($place) {
         $photos = $place->hasPhotos;
         if ($photos) {
             return $photos;
         }
     }
     return $this->notFoundResponse();
 }
Ejemplo n.º 4
0
 /**
  * store a resource 
  * @param  Request 	$request http request
  * @param  mixed  	$id      id of the resource for updating
  * @return jsend           	 jsend with newly stored source
  */
 function store(Request $request, $id = null)
 {
     ////////////////
     // Load Data  //
     ////////////////
     if ($id) {
         $data = Model::find($id);
         if (!$data) {
             return app()->abort(404);
         }
     } else {
         $data = new Model();
     }
     ///////////////////////////////////
     // Assign posted data to Data    //
     ///////////////////////////////////
     $data->fill($request->input());
     ///////////////////////////////////////////////////////////////////
     // 							Validate data 						 //
     ///////////////////////////////////////////////////////////////////
     # Validate Destinations
     $destination_id = null;
     if ($request->input('destination_id') && is_string($request->input('destination_id'))) {
         $destination = Destination::find($request->input('destination_id'));
         if ($destination) {
             $destination_id = $request->input('destination_id');
         } else {
             return response()->json(JSend::fail('InvalidDestination : Destination not found')->asArray());
         }
     } elseif (!is_string($request->input('destination_id'))) {
         return response()->json(JSend::fail('InvalidDestination : Invalid Destination format')->asArray());
     } else {
         return response()->json(JSend::fail('InvalidDestination : Destination is required')->asArray());
     }
     ///////////////////////////
     // Embeds Other Document //
     ///////////////////////////
     $data->images = $request->input('images');
     $data->tags = is_array($request->input('tags')) ? $request->input('tags') : [$request->input('tags')];
     $data->destination_id = $destination_id;
     ///////////
     // Store //
     ///////////
     if ($data->save()) {
         return response()->json(JSend::success(['data' => $data])->asArray());
     } else {
         return response()->json(JSend::fail($data->getErrors())->asArray());
     }
 }
Ejemplo n.º 5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Place::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     $query->joinWith('region');
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['lat' => $this->lat, 'lng' => $this->lng, 'location_id' => $this->location_id, 'utc_offset' => $this->utc_offset, 'user_rating_totals' => $this->user_rating_totals, 'rating' => $this->rating]);
     $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'place_id', $this->place_id])->andFilterWhere(['like', 'formatted_address', $this->formatted_address])->andFilterWhere(['like', 'adr_address', $this->adr_address])->andFilterWhere(['like', 'place.name', $this->name])->andFilterWhere(['like', 'formatted_phone_number', $this->formatted_phone_number])->andFilterWhere(['like', 'international_phone_number', $this->international_phone_number])->andFilterWhere(['like', 'icon', $this->icon])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'reference', $this->reference])->andFilterWhere(['like', 'scope', $this->scope])->andFilterWhere(['like', 'vicinity', $this->vicinity])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'region.name', $this->locationName]);
     return $dataProvider;
 }
Ejemplo n.º 6
0
 /**
  * Function get reivew by place + mozier
  *
  * @param Request $request
  * @return array|\Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function postReviewsById(Request $request)
 {
     $id_place = $request['place_id'];
     $id_mozier = $request['mozier_id'];
     $place = Place::find($id_place);
     if ($place) {
         $reviews = $place->hasReviews;
         $json = array();
         foreach ($reviews as $review) {
             $review = $this->show($review['id']);
             // Check exsits mozier id
             if ($id_mozier) {
                 // Get list liked of review
                 $liked_list = $review->hasLikeReviews;
                 if ($liked_list) {
                     if (count($liked_list) > 0) {
                         foreach ($liked_list as $liked) {
                             $mozier = $liked->mozier;
                             // Check liked of mozier
                             if ($mozier) {
                                 if ($id_mozier == $mozier['id']) {
                                     $review['is_liked'] = 1;
                                     break;
                                 } else {
                                     $review['is_liked'] = 0;
                                 }
                             } else {
                                 $review['is_liked'] = 0;
                             }
                         }
                     } else {
                         $review['is_liked'] = 0;
                     }
                 } else {
                     $review['is_liked'] = 0;
                 }
             } else {
                 $review['is_liked'] = 0;
             }
             $review->save();
             $review['number_subviews'] = count($review->hasSubReviews);
             array_push($json, $review);
         }
         return $json;
     } else {
         return $this->notFoundResponse();
     }
 }
 /**
  * Lists all CategoryGoogle models.
  * @return mixed
  */
 public function actionDownloadIcons()
 {
     $places = \app\models\Place::find()->all();
     foreach ($places as $place) {
         $model = new CategoryGoogle();
         $model->image = file_get_contents($place->icon);
         $image = \yii\web\UploadedFile::getInstance($model, 'image');
         // store the source file name
         $model->icon = $image->name;
         //            $ext = end((explode(".", $image->name)));
         // generate a unique file name
         //            $model->avatar = Yii::$app->security->generateRandomString() . ".{$ext}";
         // the path to save file, you can set an uploadPath
         // in Yii::$app->params (as used in example below)
         $path = Yii::$app->params['uploadPath'] . "icons" . $model->icon;
         if ($model->save()) {
             $image->saveAs($path);
             //                return $this->redirect(['view', 'id' => $model->_id]);
         } else {
             // error in saving model
         }
     }
     return $this->render('index', ['model' => $model]);
 }
Ejemplo n.º 8
0
 public function getPlaceAttribute()
 {
     return Place::find($this->place_id);
 }
Ejemplo n.º 9
0
 /**
  * Remove the specified resource from storage.
  *
  * @return \Illuminate\Http\Response
  */
 public function postDestroy()
 {
     if ($this->request->ajax()) {
         $id = $this->request['id'] ?: '';
         $data = Place::find($id);
         if ($data) {
             $data->delete();
         }
         $response = array('url' => route('place.index'));
         return $response;
     }
 }
Ejemplo n.º 10
0
 /**
  * Function return photos of place
  *
  * @param $id_place
  * @return mixed
  */
 public function getPhoto($id_place)
 {
     return Place::find($id_place)->hasPhotos;
 }
Ejemplo n.º 11
0
echo Html::encode($this->title);
?>
</h1>





<div class="google-detail-place-form">

    <?php 
$form = ActiveForm::begin();
?>

<?php 
$items = \yii\helpers\ArrayHelper::map(\app\models\Place::find()->where(['location_id' => $model->location_id])->all(), 'place_id', 'name');
?>
    <?php 
echo $form->field($model, 'place_id')->dropDownList($items);
?>


    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Buscar') : Yii::t('app', 'Buscar'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Ejemplo n.º 12
0
 public function actionAjaxCambiarCategoria($location_id, $category_id)
 {
     $searchModel = new \app\models\PlaceSearch();
     $query = \app\models\Place::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->join('LEFT JOIN', 'place_category', '`place_category`.`place_id`=`place`.`place_id`');
     $query->join('LEFT JOIN', 'category_google', '`place_category`.`categoria_id`=`category_google`.`id`');
     $query->join('LEFT JOIN', 'category', '`id_categoria`=`category_google`.`parent_id`');
     $query->andFilterWhere(['id_categoria' => $category_id, 'location_id' => $location_id]);
     return $this->render('_gridView', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }