bug fixes
parent
64db4abc50
commit
5a0325ea4f
|
@ -93,7 +93,7 @@ class LandingController extends BaseController
|
|||
private function getStations($district, $brand, $fuelType)
|
||||
{
|
||||
$stations=null;
|
||||
if($district!=null && $brand!=null && $fuelType!=null){
|
||||
if($district!=null && $brand!='all' && $fuelType!=null){
|
||||
$stations = Station::join('district', 'station.district', 'district.id')
|
||||
->join('fuel_price', 'station.fuel_price', 'fuel_price.id')
|
||||
->join('location', 'station.location', 'location.id')
|
||||
|
@ -101,7 +101,19 @@ 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")
|
||||
->select('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();
|
||||
}
|
||||
if($district!=null && $brand=='all' && $fuelType!=null){
|
||||
$stations = Station::join('district', 'station.district', 'district.id')
|
||||
->join('fuel_price', 'station.fuel_price', 'fuel_price.id')
|
||||
->join('location', 'station.location', 'location.id')
|
||||
->join('services', 'station.services', 'services.id')
|
||||
->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")
|
||||
->take(5)
|
||||
->get();
|
||||
}
|
||||
|
@ -419,19 +431,8 @@ $uniqueMatch1 = array();
|
|||
try{
|
||||
$statusCode = 200;
|
||||
$response['stations'] = array();
|
||||
/*[
|
||||
'districts' => []
|
||||
];*/
|
||||
$stations = $this->getStations($district, $brand, $fuelType);
|
||||
/*$stations = Station::join('district', 'station.district', 'district.id')
|
||||
->join('fuel_price', 'station.fuel_price', 'fuel_price.id')
|
||||
->join('location', 'station.location', 'location.id')
|
||||
->where('district.name','like', "%$district%")
|
||||
->where('station.brand','like', "%$brand%")
|
||||
->where("fuel_price.$fuelType",'!=', null)
|
||||
->select('station.name as stationName', 'station.brand as stationBrand', 'district.name as districtName', 'location.latitude as latitude', 'location.longitude as longitude')
|
||||
->get();*/
|
||||
//dd($stations);
|
||||
|
||||
foreach($stations as $station){
|
||||
//echo "$station";
|
||||
$data =["stationName" => $station->stationName,
|
||||
|
|
|
@ -44,7 +44,7 @@ var js = $(document).ready(function(){
|
|||
/*localStorage.setItem("district", $("#inputdistrict").val());
|
||||
localStorage.setItem("brand", $("#brand").val());
|
||||
localStorage.setItem("fuelType", $("#landingFuelType>input[name='fuelType']").val());*/
|
||||
alert("Please fill the data");
|
||||
//alert("Please fill the data");
|
||||
}else {
|
||||
var fuelType=new Array();
|
||||
var district=localStorage.getItem("district");
|
||||
|
@ -54,15 +54,21 @@ var js = $(document).ready(function(){
|
|||
var fuelType=$("#landingFuelType>input[name='fuelType']").val();
|
||||
var brand=$("#brand").val();*/
|
||||
var stationsData;
|
||||
|
||||
var link = null;
|
||||
if(brand===undefined || brand===''){
|
||||
link= "api/stations/"+district+"/all/"+fuelType[0];
|
||||
}else{
|
||||
link= "api/stations/"+district+"/"+brand+"/"+fuelType[0];
|
||||
}
|
||||
console.log(link);
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: "api/stations/"+district+"/"+brand+"/"+fuelType[0],
|
||||
url: link,
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
stationsData = data["stations"];
|
||||
console.table(stationsData);
|
||||
//console.table(stationsData);
|
||||
},
|
||||
|
||||
error: function (textStatus, errorThrown) {
|
||||
|
@ -72,7 +78,7 @@ var js = $(document).ready(function(){
|
|||
});
|
||||
|
||||
}
|
||||
console.log(stationsData);
|
||||
//console.table(stationsData);
|
||||
return stationsData;
|
||||
|
||||
}
|
||||
|
@ -98,7 +104,7 @@ var js = $(document).ready(function(){
|
|||
var markers=new Array();
|
||||
markers.push(getStations());
|
||||
//console.log(markers);
|
||||
placeMarker(map, markers);
|
||||
placeMarker(map, markers);
|
||||
|
||||
|
||||
}
|
||||
|
@ -111,7 +117,7 @@ var js = $(document).ready(function(){
|
|||
new google.maps.Marker({
|
||||
position: {"lat": parseFloat(marker[i].latitude), "lng": parseFloat(marker[i].longitude)},
|
||||
map: map,
|
||||
title: 'Fuel Station'
|
||||
title: marker[i].stationName
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -32,23 +32,23 @@
|
|||
<br>
|
||||
<div class="checkbox" id="landingFuelType">
|
||||
|
||||
<label><input type="checkbox" name="fuelType" value="diesel">Gasóleo</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="diesel_simple">Gasóleo Simples</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="diesel_colored">Gasóleo Colorido</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="diesel_special">Gasóleo Especial</label><br>
|
||||
<label><input type="radio" name="fuelType" value="diesel">Gasóleo</label><br>
|
||||
<label><input type="radio" name="fuelType" value="diesel_simple">Gasóleo Simples</label><br>
|
||||
<label><input type="radio" name="fuelType" value="diesel_colored">Gasóleo Colorido</label><br>
|
||||
<label><input type="radio" name="fuelType" value="diesel_special">Gasóleo Especial</label><br>
|
||||
<br><br>
|
||||
<label><input type="checkbox" name="fuelType" value="petrol_95">Gasolina 95</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="petrol_simple_95">Gasolina Simples 95</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="petrol_special_95">Gasolina Especial 95</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_95">Gasolina 95</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_simple_95">Gasolina Simples 95</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_special_95">Gasolina Especial 95</label><br>
|
||||
<br><br>
|
||||
<label><input type="checkbox" name="fuelType" value="petrol_98">Gasolina 98</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="petrol_simple_98">Gasolina Simples 98</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="petrol_special_98">Gasolina Especial 98</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_98">Gasolina 98</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_simple_98">Gasolina Simples 98</label><br>
|
||||
<label><input type="radio" name="fuelType" value="petrol_special_98">Gasolina Especial 98</label><br>
|
||||
<br><br>
|
||||
<label><input type="checkbox" name="fuelType" value="gas_natural_compressed_kg">GNC KG</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="gas_natural_compressed_m3">GNC M3</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="gas_natural_liquified">GNL</label><br>
|
||||
<label><input type="checkbox" name="fuelType" value="gpl">GPL</label><br>
|
||||
<label><input type="radio" name="fuelType" value="gas_natural_compressed_kg">GNC KG</label><br>
|
||||
<label><input type="radio" name="fuelType" value="gas_natural_compressed_m3">GNC M3</label><br>
|
||||
<label><input type="radio" name="fuelType" value="gas_natural_liquified">GNL</label><br>
|
||||
<label><input type="radio" name="fuelType" value="gpl">GPL</label><br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
@ -78,10 +78,12 @@
|
|||
<input type="hidden" name="brand" value="">
|
||||
<button id="landingBack">Back</button>
|
||||
</form>
|
||||
<p>Mais baratas</p>
|
||||
|
||||
{{$stations}}
|
||||
|
||||
<p>Mais baratas ()</p>
|
||||
@foreach($stations as $station)
|
||||
Nome: {{$station->stationName}}<br>
|
||||
Preço: {{$station->fuelPrice}}<br>
|
||||
Services: {{$station->services}}<br>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue