Exemplo n.º 1
0
 public function afterSave($event)
 {
     $model = $this->owner;
     $es = $this->path_elements[$model->path];
     foreach ($es as $value) {
         $place = new Place();
         $place->title = $value;
         $place->layout_id = $model->id;
         $place->save();
     }
 }
Exemplo n.º 2
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());
     }
 }
Exemplo n.º 3
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $place = Place::with(['city', 'category'])->whereId($id)->first();
     $categories = Category::all();
     $cities = City::all();
     return view('client.placeinfo', compact('place', 'categories', 'cities'));
 }
Exemplo n.º 4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($date)
 {
     $date = Carbon::createFromFormat('U', $date)->format('Y-m-d');
     $visit = Visit::where('date', '=', $date)->with('place')->first();
     $places = Place::where('active', '=', 1)->orderBy('placename')->lists('placename', 'id')->all();
     return view('visit._edit', compact('visit', 'places'));
 }
Exemplo n.º 5
0
 function actionFix()
 {
     $count = CitymapAddress::find()->select('itemid')->where('areaid IS NULL')->count();
     $this->_report("Найдено {$count} записей с незаполненным areaid");
     //dgis
     $dgis_regions_response = json_decode(file_get_contents("http://catalog.api.2gis.ru/2.0/region/list?key=ruffzo9376&locale_filter=ru_RU&fields=items.settlements"));
     $dgis_regions = [];
     foreach ($dgis_regions_response->result->items as $region) {
         $dgis_regions[$region->name] = $region->name;
         if (!empty($region->settlements)) {
             foreach ($region->settlements as $settlement) {
                 $dgis_regions[$settlement] = $region->name;
             }
         }
     }
     //$count = 5085285;
     $size = 1000;
     $pages = ceil($count / $size);
     $geos = [];
     for ($i = 0; $i <= $pages; $i++) {
         $this->_report("Страница {$i} из {$pages}");
         $records = CitymapAddress::find()->where('areaid IS NULL')->limit($size)->offset($i * $size)->all();
         foreach ($records as $rec) {
             $short_lat = substr($rec->place_lat, 0, 2);
             $short_lng = substr($rec->place_lng, 0, 2);
             $code = $short_lng . '#' . $short_lat;
             if (empty($geos[$code])) {
                 $this->_report("Обновляем {$code}");
                 $city = "";
                 $query = "https://geocode-maps.yandex.ru/1.x/?format=json&geocode=" . $rec->place_lng . ',' . $rec->place_lat;
                 $geocode = json_decode(file_get_contents($query));
                 if (!$geocode->response->GeoObjectCollection->metaDataProperty->GeocoderResponseMetaData->found) {
                     $this->_report($code . ' не найдено ничего по запросу (0 results) $query');
                     continue;
                 }
                 //$this->_report("Ищем город по координатам");
                 $features = $geocode->response->GeoObjectCollection->featureMember;
                 foreach ($features as $feature) {
                     if ($feature->GeoObject->metaDataProperty->GeocoderMetaData->kind == 'locality') {
                         if (isset($dgis_regions[$feature->GeoObject->name]) && ($city = Place::findOne(['name' => $dgis_regions[$feature->GeoObject->name]]))) {
                             //$this->_report("Записываем в базу {$feature->GeoObject->name} areaid {$city->areaid}");
                             $updated = CitymapAddress::updateAll(['areaid' => $city->areaid], "areaid IS NULL AND place_lat LIKE '{$short_lat}%' AND place_lng LIKE '{$short_lng}%'");
                             $ct = $dgis_regions[$feature->GeoObject->name];
                             $this->_report("Записано: {$updated} город {$ct}");
                             $geos[$code] = $city->name;
                             break;
                         } else {
                             $this->_report("Locality {$feature->GeoObject->name} найден, но в базе тугис такой отсутствует {$query}");
                             break;
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 public function wait($myVote)
 {
     $places = Place::all();
     $view = view('main.wait');
     $view->with('places', $places);
     $view->with('infoMsg', 'Glasal si za ' . $myVote->place->name . ' još stignes promeniti.');
     $view->with('myVote', $myVote);
     $view->with('expire', $this->todayOrder->dateFormated);
     $view->with('me', $this->loggedUser->name);
     return $view;
 }
Exemplo n.º 7
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');
 }
Exemplo n.º 8
0
 public function getPhotoByPlace($id_place)
 {
     $place = Place::find($id_place);
     if ($place) {
         $photos = $place->hasPhotos;
         if ($photos) {
             return $photos;
         }
     }
     return $this->notFoundResponse();
 }
Exemplo n.º 9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $place = Place::findOrFail($id->id);
     $input = $request->all();
     $input['active'] = $request->has('active') ? true : false;
     //        if($request->has('cuisine')) {
     //            dd($request->cuisine);
     //        }
     $place->fill($input)->save();
     $place->cuisine()->sync($request->cuisine);
     //        Session::flash('flash_message', 'Task successfully added!');
     return redirect()->back();
 }
Exemplo n.º 10
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;
 }
Exemplo n.º 11
0
 public function search($input)
 {
     $query = Place::query();
     $columns = Schema::getColumnListing('places');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
Exemplo n.º 12
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]);
 }
Exemplo n.º 14
0
 public function getPlace()
 {
     return $this->hasOne(Place::className(), ['id' => 'place_id']);
 }
Exemplo n.º 15
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;
     }
 }
Exemplo n.º 16
0
 public function __construct(Request $request)
 {
     $this->places = Place::all('id', 'name');
     $this->request = $request;
 }
Exemplo n.º 17
0
 /**
  * Function return place around user
  *
  * @param Request $request
  * @return array
  */
 public function getAroundPlace(Request $request)
 {
     $latitude = $request['latitude'];
     $longitude = $request['longitude'];
     $range_meter = $request['range'];
     $place_list = Place::all();
     $around_list = array();
     foreach ($place_list as $place) {
         $latitude_place = $place['latitude'];
         $longitude_place = $place['longitude'];
         $place = $this->show($place['id']);
         $range = $this->distance($latitude, $longitude, $latitude_place, $longitude_place, 'M');
         if ($range <= $range_meter) {
             array_push($around_list, $place);
         }
     }
     return $around_list;
 }
Exemplo n.º 18
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();
?>
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $place = \App\Models\Place::findOrFail($id);
     $place->delete();
     return redirect(route('place.index'));
 }
Exemplo n.º 20
0
 public static function getPlaceById($place_id)
 {
     return Place::where('place_id', $place_id)->first();
 }
Exemplo n.º 21
0
 /**
  * Display a randomized place.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $places = Place::where('active', '=', true)->get();
     $place = $places->random(1);
     return view('pick.index', compact('place'));
 }
Exemplo n.º 22
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]);
 }
 public function genXml()
 {
     $center_lat = $_GET['lat'];
     $center_lng = $_GET['lng'];
     $radius = $_GET['radius'];
     $datas = Place::select(DB::raw("`place_id`,`name`,`address`, `lat`, `lng`, ( 6371 * acos( cos( radians(?) ) * cos( radians( `lat`) ) * cos( radians( `lng` ) - radians(?) ) + sin( radians(?) ) * sin( radians( `lat` ) ) ) ) AS `distance`"))->havingRaw("distance < ?")->orderBy("distance")->limit("20")->setBindings([$center_lat, $center_lng, $center_lat, $radius])->get()->toArray();
     // $rs_post_id = Post::getPostByPlaceId($datas['place_id']);
     $xml = new XMLWriter();
     $xml->openMemory();
     $xml->startDocument();
     $xml->startElement('markers');
     foreach ($datas as $row) {
         $xml->startElement('marker');
         $xml->writeAttribute('name', $row['name']);
         $xml->writeAttribute('address', $row['address']);
         $xml->writeAttribute('lat', $row['lat']);
         $xml->writeAttribute('lng', $row['lng']);
         $xml->writeAttribute('place_id', $row['place_id']);
         $xml->endElement();
     }
     $xml->endElement();
     $xml->endDocument();
     $content = $xml->outputMemory();
     $xml = null;
     return response($content)->header('Content-Type', 'text/xml');
 }
Exemplo n.º 24
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPlaceCategories()
 {
     return $this->hasMany(Place::className(), ['place_id' => 'place_id'])->viaTable('place_category', ['place_id' => 'place_id']);
 }
Exemplo n.º 25
0
 public function getPlaces()
 {
     return $this->hasMany(Place::className(), ['logo' => 'id']);
 }
Exemplo n.º 26
0
 public function run()
 {
     Place::truncate();
     Place::create(['name_place' => 'BETA FST UNAIR', 'price_black' => 250, 'price_color' => 400]);
     Place::create(['name_place' => 'FEB UNAIR', 'price_black' => 250, 'price_color' => 400]);
 }
Exemplo n.º 27
0
 public function getPlaces()
 {
     return $this->hasMany(Place::className(), ['currency_code' => 'code']);
 }
Exemplo n.º 28
0
 public function getPlaceAttribute()
 {
     return Place::find($this->place_id);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($post_id)
 {
     //
     $post = $this->getPostDetail($post_id)[0];
     $post_stat = $this->getPostDetail($post_id)[1];
     if (Auth::check()) {
         $post["liked"] = LikeEvent::checkLiked($post["post_id"], Auth::user()->user_id);
     }
     $post["comments"] = Post::getCommentsByPostId($post_id);
     $post["likes"] = $post_stat["likes"];
     $post["pins"] = $post_stat["pins"];
     $post["boards"] = Board::getPostsInBoard($post["board_id"]);
     $post["places"] = Place::getPlaceById(Post::getPostById($post_id)['place_id']);
     $recommend = new RecommendController();
     $post["recommend_posts"] = $recommend->getPost($post_id);
     return response()->json($post);
 }