Date: Sat, 2 Jun 2018 18:49:57 +0100
Subject: [PATCH 3/3] Update documentation
---
app/Console/Commands/GpsCommand.php | 70 -------------------
.../Controllers/ApiV1/IndexController.php | 16 ++---
app/Http/Controllers/ExampleController.php | 18 -----
app/Http/Middleware/ExampleMiddleware.php | 20 ------
resources/views/index.blade.php | 42 +++--------
5 files changed, 15 insertions(+), 151 deletions(-)
delete mode 100644 app/Console/Commands/GpsCommand.php
delete mode 100644 app/Http/Controllers/ExampleController.php
delete mode 100644 app/Http/Middleware/ExampleMiddleware.php
diff --git a/app/Console/Commands/GpsCommand.php b/app/Console/Commands/GpsCommand.php
deleted file mode 100644
index a33ac1d..0000000
--- a/app/Console/Commands/GpsCommand.php
+++ /dev/null
@@ -1,70 +0,0 @@
-select("SELECT DISTINCT cp4, cp3 FROM ctt where district_id = 8 AND latitude IS NULL ORDER BY cp3;");
-
- $client = new \GuzzleHttp\Client();
- foreach($results as $result) {
- $url = sprintf($gpsUrl, $result->cp4, $result->cp3);
- $res = $client->request('GET', $url);
- $body = (string)$res->getBody();
- $dom = HtmlDomParser::str_get_html($body);
- $gps = $dom->find('span[class="pull-right gps"]',0)->innertext;
- if($gps) {
- $gps = trim(str_replace('GPS:','',$gps));
- $parts = explode(',',$gps);
- if(!is_array($parts) || count($parts) != 2){
- continue;
- }
- list($lat, $long) = $parts;
- $lat = floatval($lat);
- $long = floatval($long);
- DB::table('ctt')->where([
- ['cp4', '=', $result->cp4],
- ['cp3', '=', $result->cp3],
- ])->update(['latitude' => $lat,'longitude' => $long]);
- echo($result->cp4.'-'.$result->cp3.' -> '.$lat.'/'.$long."\n");
-
- } else {
- echo($result->cp4.'-'.$result->cp3." -> \n");
- }
-
- sleep(1);
-
- }
- }
-
-}
diff --git a/app/Http/Controllers/ApiV1/IndexController.php b/app/Http/Controllers/ApiV1/IndexController.php
index 67b216f..2f2a0ea 100644
--- a/app/Http/Controllers/ApiV1/IndexController.php
+++ b/app/Http/Controllers/ApiV1/IndexController.php
@@ -9,7 +9,7 @@
class IndexController extends Controller
{
-
+
public function Index(Request $request, $cp3, $cp4)
{
$results = DB::table('ctt')
@@ -25,8 +25,6 @@ public function Index(Request $request, $cp3, $cp4)
['ctt.cp3', '=', $cp3],
])->get();
-
-
$data = [];
foreach($results as $result) {
$data[] = $this->normalizeData($result);
@@ -34,8 +32,8 @@ public function Index(Request $request, $cp3, $cp4)
return response()->json($data);
}
-
-
+
+
public function Random()
{
$id = DB::table('ctt')
@@ -55,7 +53,8 @@ public function Random()
return response()->json($this->normalizeData($result));
}
-
+
+
protected function normalizeData($result)
{
$fullAddress = [];
@@ -80,7 +79,7 @@ protected function normalizeData($result)
}
if(!empty(trim($result->porta))) {
- $fullAddress[] = trim($result->porta);
+ $fullAddress[] = ', '.trim($result->porta);
}
return [
@@ -99,6 +98,5 @@ protected function normalizeData($result)
'longitude' => $result->longitude,
];
}
-
-}
+}
diff --git a/app/Http/Controllers/ExampleController.php b/app/Http/Controllers/ExampleController.php
deleted file mode 100644
index de8f6da..0000000
--- a/app/Http/Controllers/ExampleController.php
+++ /dev/null
@@ -1,18 +0,0 @@
-
[
{
- "name": "Lisboa",
- "district": "Lisboa",
- "municipality": "Lisboa",
- "id": 136883,
- "location_id": 21696,
- "municipality_id": 6,
- "district_id": 11,
- "art_cod": "300460611",
- "art_tipo": "Rossio",
- "pri_prep": "dos",
- "art_titulo": "",
- "seg_prep": "",
- "art_desig": "Olivais",
- "art_local": "",
- "troco": "",
- "porta": "",
- "cliente": "",
+ "locationName": "Lisboa",
+ "fullAddress": "Rossio dos Olivais",
+ "zone": "",
+ "section": "",
+ "doorNumber": "",
+ "clientName": "",
"cp4": "1990",
"cp3": "231",
"cpalf": "LISBOA",
+ "districtName": "Lisboa",
+ "municipalityName": "Lisboa",
"latitude": null,
"longitude": null
}
]
-2.1 Labels (portuguese only)
-
- name Nome da localidade
- art_cod Código da Artéria
- art_tipo Artéria - Tipo (Rua, Praça, etc)
- pri_prep Primeira preposição
- art_titulo Artéria - Titulo (Doutor, Eng.º, Professor, etc)
- seg_prep Segunda preposição
- art_desig Artéria - Designação
- art_local Artéria - Informação do Local/Zona
- troco Descrição do troço
- porta Número da porta do cliente
- cliente Nome do cliente
- cp4 N.º do código postal
- cp3 Extensão do n.º do código postal
- cpalf Designação Postal
-
3. Random ZipCode
If you need data from a random zipcode:
{{$host}}/api/v1/random