Details Page
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
|
||||
use App\Station;
|
||||
|
||||
class DetailsController extends Controller
|
||||
{
|
||||
public function index($id)
|
||||
{
|
||||
$stationData = Station::join('fuel_price', 'station.fuel_price', 'fuel_price.id')
|
||||
->where('station.id', $id)
|
||||
->first();
|
||||
return View('details', ['stationData'=>$stationData]);
|
||||
}
|
||||
|
||||
public function apiStation($id){
|
||||
$station = Station::join('location', 'station.location', 'location.id')
|
||||
->where('station.id', $id)
|
||||
->select('latitude', 'longitude')
|
||||
->first();
|
||||
return Response::json(["station"=> $station]);
|
||||
}
|
||||
}
|
|
@ -95,7 +95,7 @@ class LandingController extends BaseController
|
|||
->where('station.brand','like', "%$brand%")
|
||||
->where("fuel_price.$fuelType",'!=', null)
|
||||
->orderBy("fuel_price.$fuelType", "asc")
|
||||
->select('station.name as stationName', "station.brand as stationBrand", "district.name as districtName", "fuel_price.$fuelType as fuelPrice", "latitude", "longitude", "$fuelType as fuelType")
|
||||
->select('station.id as stationId', 'station.name as stationName', "station.brand as stationBrand", "district.name as districtName", "fuel_price.$fuelType as fuelPrice", "latitude", "longitude", "$fuelType as fuelType")
|
||||
->take(5)
|
||||
->get();
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class LandingController extends BaseController
|
|||
->where('district.name','like', "%$district%")
|
||||
->where("fuel_price.$fuelType",'!=', null)
|
||||
->orderBy("fuel_price.$fuelType", "asc")
|
||||
->select('station.name as stationName', "station.brand as stationBrand", "district.name as districtName", "fuel_price.$fuelType as fuelPrice", "latitude", "longitude", "$fuelType as fuelType")
|
||||
->select('station.id as stationId', 'station.name as stationName', "station.brand as stationBrand", "district.name as districtName", "fuel_price.$fuelType as fuelPrice", "latitude", "longitude", "$fuelType as fuelType")
|
||||
->take(5)
|
||||
->get();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,9 @@ class UserPageController extends Controller
|
|||
private $coordinates;
|
||||
private $distanceY = 5;
|
||||
private $distanceX = 5;
|
||||
|
||||
private $mainFuel;
|
||||
private $latitudeOrigin;
|
||||
private $longitudeOrigin;
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
@ -346,18 +348,16 @@ class UserPageController extends Controller
|
|||
Session::forget('coordinates');
|
||||
Session::forget('vehicleId');
|
||||
Session::forget('autonomyKm');
|
||||
// Cache::forget('latitudeOrigin');
|
||||
// Cache::forget('longitudeOrigin');
|
||||
Session::forget('latitudeOrigin');
|
||||
Session::forget('longitudeOrigin');
|
||||
|
||||
Session::put("coordinates", $request->points);
|
||||
Session::put("vehicleId", $request->vehicleId);
|
||||
Session::put("autonomyKm", $request->distance);
|
||||
Session::put("latitudeOrigin",$request->latitudeOrigin);
|
||||
Session::put("longitudeOrigin", $request->longitudeOrigin);
|
||||
Cache::put('latitudeOrigin', $request->latitudeOrigin, 4);//2 minutes
|
||||
Cache::put('longitudeOrigin', $request->longitudeOrigin, 4);
|
||||
/*$request->latitude = null;
|
||||
$request->longitude = null;*/
|
||||
Session::put('latitudeOrigin', $request->latitudeOrigin);
|
||||
Session::put('longitudeOrigin', $request->longitudeOrigin);
|
||||
|
||||
return Response::json(["data"=> $data, "vehicleId"=> vehicleId, $request->vehicleId=> distance, "latitudeOrigin"=> $request->latitudeOrigin, "longitudeOrigin"=> $request->longitudeOrigin]);
|
||||
}
|
||||
|
@ -366,8 +366,10 @@ class UserPageController extends Controller
|
|||
$data = Session::get("coordinates");
|
||||
$vehicleData = Session::get("vehicleId");
|
||||
$autonomyKmData = Session::get("autonomyKm");
|
||||
$latitudeOrigin = Cache::get('latitudeOrigin');//Session::get("latitudeOrigin");
|
||||
$longitudeOrigin = Cache::get('longitudeOrigin');//Session::get("longitudeOrigin");
|
||||
$latitudeOrigin = Session::get('latitudeOrigin');
|
||||
$longitudeOrigin = Session::get('longitudeOrigin');
|
||||
Session::forget('latitudeOrigin');
|
||||
Session::forget('longitudeOrigin');
|
||||
|
||||
$data = json_encode($data);
|
||||
$data = json_decode($data, true);
|
||||
|
@ -435,6 +437,7 @@ class UserPageController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
$this->mainFuel = $vehicleFuels[0];
|
||||
//order array by price
|
||||
usort($stationsArray, array($this, "sortByPriceLower"));
|
||||
|
||||
|
@ -489,9 +492,8 @@ class UserPageController extends Controller
|
|||
}
|
||||
|
||||
public function sortByPriceLower($station1, $station2){
|
||||
//echo round($station2[0]->petrol_95_simple, 3) - round($station1[0]->petrol_95_simple, 3);
|
||||
//if (round($station2[0]->petrol_95_simple, 3) < round($station1[0]->petrol_95_simple, 3)) {
|
||||
$result = round($station2->petrol_95_simple, 3) - round($station1->petrol_95_simple, 3);
|
||||
$fuel =$this->mainFuel->fuelName;
|
||||
$result = round($station2->$fuel, 3) - round($station1->$fuel, 3);
|
||||
$result<0?-1:1;
|
||||
|
||||
return $result;
|
||||
|
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 9.5 KiB |
|
@ -159,7 +159,30 @@ var array2;
|
|||
zoom: 7,
|
||||
center: {lat: 39.7495, lng: -8.8077}
|
||||
});
|
||||
var currentUrl = window.location.href;
|
||||
var id = currentUrl.match(/\d+/g);
|
||||
var coordinates = {lat: null, lng:null};
|
||||
$.ajax({
|
||||
async:false,
|
||||
url: '/api/station/'+id[0],//'http://geocomb.app/receiveCoords',
|
||||
type: 'GET',
|
||||
|
||||
success: function (response) {
|
||||
//console.log("data sent "+ response["station"].latitude);
|
||||
coordinates.lat = response["station"].latitude;
|
||||
coordinates.lng = response["station"].longitude;
|
||||
|
||||
},
|
||||
error: function(error){
|
||||
console.log("could not send data, error: ");
|
||||
console.table(error);
|
||||
}
|
||||
});
|
||||
|
||||
new google.maps.Marker({
|
||||
position: {"lat": parseFloat(coordinates.lat), "lng": parseFloat(coordinates.lng)},
|
||||
map: map,
|
||||
});
|
||||
}
|
||||
|
||||
function getLocation() {
|
||||
|
@ -380,7 +403,7 @@ var array2;
|
|||
var distance = $('#upAutonomyKm').val();
|
||||
console.log("distance: "+ distance);
|
||||
|
||||
console.log("latitude origin: "+coordinates.origin.latitude);
|
||||
console.log("latitude origin: "+coordinates.origin.latitude+" longitude origin: "+coordinates.origin.longitude);
|
||||
|
||||
var directionsService = new google.maps.DirectionsService();
|
||||
var directionsDisplay = new google.maps.DirectionsRenderer({
|
||||
|
@ -470,8 +493,8 @@ var array2;
|
|||
$.ajax({
|
||||
async: false,
|
||||
url: link,
|
||||
crossDomain: true,
|
||||
type: "GET",
|
||||
url: "https://maps.googleapis.com/maps/api/elevation/json?path="+coordinates.origin.latitude+","+coordinates.origin.longitude+"|"+coordinates.destination.latitude+","+coordinates.destination.longitude+"&samples=15&key="+key,
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
stationData = data['station'];
|
||||
|
|
|
@ -17,19 +17,19 @@
|
|||
|
||||
<div class="col-lg-12">
|
||||
|
||||
<h3><strong>Nome: </h3></strong><br>
|
||||
<h3><strong>Marca: </h3></strong><br><br>
|
||||
<h3><strong>Nome: @if(isset($stationData)){{$stationData->name}}@endif </h3></strong><br>
|
||||
<h3><strong>Marca: @if(isset($stationData)){{$stationData->brand}}@endif </h3></strong><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<h4><strong>Gasóleo - </h4></strong><br>
|
||||
<h4><strong>Gasóleo Simples - </h4></strong><br>
|
||||
<h4><strong>Gasóleo Colorido - </h4></strong><br>
|
||||
<h4><strong>Gasóleo Especial - </h4></strong><br>
|
||||
<h4><strong>Gasóleo - @if(isset($stationData)){{$stationData->diesel}}@endif €</h4></strong><br>
|
||||
<h4><strong>Gasóleo Simples - @if(isset($stationData)){{$stationData->diesel_simple}}@endif €</h4></strong><br>
|
||||
<h4><strong>Gasóleo Colorido -</h4></strong><br>
|
||||
<h4><strong>Gasóleo Especial - @if(isset($stationData)){{$stationData->diesel_special}}@endif €</h4></strong><br>
|
||||
<br><br>
|
||||
<h4><strong>Gasolina 95 - </h4></strong><br>
|
||||
<h4><strong>Gasolina Simples 95 - </h4></strong><br>
|
||||
<h4><strong>Gasolina 95 - @if(isset($stationData)){{$stationData->petrol_95 }}@endif €</h4></strong><br>
|
||||
<h4><strong>Gasolina Simples 95 - @if(isset($stationData)){{$stationData->petrol_95_simple }}@endif €</h4></strong><br>
|
||||
<h4><strong>Gasolina Especial 95 - </h4></strong><br>
|
||||
<br><br>
|
||||
</div>
|
||||
|
@ -38,10 +38,10 @@
|
|||
<h4><strong>GNC KG - </h4></strong><br>
|
||||
<h4><strong>GNC M3 - </h4></strong><br>
|
||||
<h4><strong>GNL - </h4></strong><br>
|
||||
<h4><strong>GPL - </h4></strong><br>
|
||||
<h4><strong>GPL - @if(isset($stationData)){{$stationData->gpl}}@endif €</h4></strong><br>
|
||||
<br><br>
|
||||
<h4><strong>Gasolina 98 - </h4></strong><br>
|
||||
<h4><strong>Gasolina Simples 98 - </h4></strong><br>
|
||||
<h4><strong>Gasolina 98 - @if(isset($stationData)){{$stationData->petrol_98 }}@endif €</h4></strong><br>
|
||||
<h4><strong>Gasolina Simples 98 - @if(isset($stationData)){{$stationData->petrol_98_simple}}@endif €</h4></strong><br>
|
||||
<h4><strong>Gasolina Especial 98 - </h4></strong><br>
|
||||
<br><br>
|
||||
</div>
|
||||
|
|
|
@ -114,6 +114,8 @@
|
|||
<label for="nome">Preço: </label>
|
||||
{{$station->fuelPrice}}
|
||||
|
||||
<a href="{{route('stationDetails', $station->stationId)}}">Station Details</a>
|
||||
|
||||
<!--<button type="button" class="btn btn-link" style="float:right">Detalhes</button>-->
|
||||
<img src="../../files/{{$key+1}}.jpg"></img>
|
||||
<br>
|
||||
|
|
|
@ -73,12 +73,14 @@ Route::group(['middleware' => 'auth'], function () {
|
|||
});
|
||||
|
||||
Route::post('/showGpsCoordinates', 'LandingController@index');
|
||||
Route::get('/station/details/{id}', 'DetailsController@index')->name('stationDetails');
|
||||
|
||||
//API
|
||||
Route::get('/api/districts', 'LandingController@apiDistricts')->name('apidistricts');
|
||||
Route::get('/api/brands', 'LandingController@apiBrands')->name('apibrands');
|
||||
Route::get('/api/stations/{district}/{brand}/{fuelType}', 'LandingController@apiStations')->name('apistations');
|
||||
Route::get('/api/stationsup/{origin}/{destination}/{autonomy}', 'UserPageController@apiStations')->name('apistationsup');
|
||||
Route::get('/api/station/{id}', 'DetailsController@apiStation')->name('apiStation');
|
||||
|
||||
Route::post('/receiveCoords','UserPageController@receiveCoordinates');
|
||||
Route::get('/receivedCoords','UserPageController@receivedCoordinates');
|
||||
|
|