Fix bug on landing page
parent
153985d834
commit
f8f3330171
|
@ -69,6 +69,7 @@ class LandingController extends BaseController
|
|||
array_push($brandsName, $brands[$i]->brand);
|
||||
}
|
||||
|
||||
|
||||
$stations = array();
|
||||
$stations = $this->getStations($request->district, $request->brand, $request->fuelType);
|
||||
|
||||
|
@ -86,30 +87,35 @@ class LandingController extends BaseController
|
|||
|
||||
private function getStations($district, $brand, $fuelType)
|
||||
{
|
||||
// echo $fuelType[0];
|
||||
|
||||
$stations=null;
|
||||
if($district!=null && $brand!='all' && $fuelType!=null){
|
||||
$stations = Station::join('district', 'station.district', 'district.id')
|
||||
$query= 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)
|
||||
->orderBy("fuel_price.$fuelType", "asc")
|
||||
->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();
|
||||
->where('station.brand','like', "%$brand%");
|
||||
foreach($fuelType as $key=>$val)
|
||||
$query->where("fuel_price.$fuelType[$key]",'!=', null);
|
||||
foreach($fuelType as $key=>$val)
|
||||
$query->orderBy("fuel_price.$fuelType[$key]", "asc");
|
||||
$query->select('station.id as stationId', 'station.name as stationName', "station.brand as stationBrand", "district.name as districtName", "fuel_price.$fuelType[0] as fuelPrice", "latitude", "longitude", "$fuelType[0] as fuelType")
|
||||
->take(5);
|
||||
$stations = $query->get();
|
||||
}
|
||||
if($district!=null && $brand=='all' && $fuelType!=null){
|
||||
$stations = Station::join('district', 'station.district', 'district.id')
|
||||
$query = 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.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();
|
||||
->where('district.name','like', "%$district%");
|
||||
foreach($fuelType as $key=>$val)
|
||||
$query->where("fuel_price.$fuelType[$key]",'!=', null);
|
||||
foreach($fuelType as $key=>$val)
|
||||
$query->orderBy("fuel_price.$fuelType[$key]", "asc");
|
||||
$query->select('station.id as stationId', 'station.name as stationName', "station.brand as stationBrand", "district.name as districtName", "fuel_price.$fuelType[0] as fuelPrice", "latitude", "longitude", "$fuelType[0] as fuelType")
|
||||
->take(5);
|
||||
$stations = $query->get();
|
||||
}
|
||||
return $stations;
|
||||
|
||||
|
@ -439,9 +445,10 @@ $uniqueMatch1 = array();
|
|||
|
||||
public function apiStations($district, $brand, $fuelType) {
|
||||
try{
|
||||
$array = explode(',', $fuelType);
|
||||
$statusCode = 200;
|
||||
$response['stations'] = array();
|
||||
$stations = $this->getStations($district, $brand, $fuelType);
|
||||
$stations = $this->getStations($district, $brand, $array);
|
||||
|
||||
foreach($stations as $station){
|
||||
//echo "$station";
|
||||
|
@ -451,13 +458,8 @@ $uniqueMatch1 = array();
|
|||
"latitude" => $station->latitude,
|
||||
"longitude" => $station->longitude
|
||||
];
|
||||
array_push($response["stations"], $data /*[
|
||||
'id' => $district->id,*/
|
||||
//'name' =>
|
||||
//]
|
||||
);
|
||||
array_push($response["stations"], $data);
|
||||
}
|
||||
//dd($response);
|
||||
|
||||
}catch (Exception $e){
|
||||
$statusCode = 400;
|
||||
|
|
|
@ -128,8 +128,10 @@ var array2;
|
|||
center: pt
|
||||
});
|
||||
|
||||
var markers=new Array();
|
||||
markers.push(getStations());
|
||||
var markers=new Array(getStations());
|
||||
console.log("markers");
|
||||
console.table(markers);
|
||||
markers.push(markers);
|
||||
|
||||
var myLatLng = {"lat": 39.7495, "lng":-8.8077};
|
||||
var labels = '12345';
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
@if (Auth::user())
|
||||
<li><a href="{{route('planRoute')}}"><h4>My Area</h4></a></li>
|
||||
<li><a href="{{route('planRoute')}}"><h4>Área Pessoal</h4></a></li>
|
||||
@endif
|
||||
|
||||
@if (Auth::guest())
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
<br><br>
|
||||
<div class="container-fluid" style="background-color: grey">
|
||||
<h2 class="center">Pesquisar Postos:</h2>
|
||||
<a href="{{route('details')}}">DETALHES</a>
|
||||
<br><br><br>
|
||||
|
||||
<div class="row">
|
||||
|
@ -37,15 +36,16 @@
|
|||
<div class="row">
|
||||
<div class="checkbox-inline" id="landingFuelType">
|
||||
<div class="form-group" style="text-align:center">
|
||||
<label style="font-weight:bold">Tipo de Combustível (Escolha 1): </label>
|
||||
<label style="font-weight:bold">Tipo de Combustível: </label>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12">
|
||||
@if($fuels)
|
||||
@foreach($fuels as $fuel)
|
||||
<label><input type="checkbox" name="fuelType" value="{{$fuel->name}}">@if($fuel->name == "petrol_95") Gasolina 95 @elseif($fuel->name == "petrol_95_simple") Gasolina 95 Simples @elseif($fuel->name == "petrol_98") Gasolina 98 @elseif($fuel->name == "petrol_98_simple") Gasolina 98 Simples @elseif($fuel->name == "diesel") Diesel @elseif($fuel->name == "diesel_simple") Diesel Simples @elseif($fuel->name == "gpl") GPL @endif</label><br>
|
||||
<label><input type="checkbox" name="fuelType[]" value="{{$fuel->name}}">@if($fuel->name == "petrol_95") Gasolina 95 @elseif($fuel->name == "petrol_95_simple") Gasolina 95 Simples @elseif($fuel->name == "petrol_98") Gasolina 98 @elseif($fuel->name == "petrol_98_simple") Gasolina 98 Simples @elseif($fuel->name == "diesel") Diesel @elseif($fuel->name == "diesel_simple") Diesel Simples @elseif($fuel->name == "gpl") GPL @endif</label><br>
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
</div>
|
||||
<!--
|
||||
<div class="col-lg-6">
|
||||
<label class="checkbox-inline"><input type="checkbox" name="fuelType" value="diesel">Gasóleo</label><br>
|
||||
<label class="checkbox-inline"><input type="checkbox" name="fuelType" value="diesel_simple">Gasóleo Simples</label><br>
|
||||
|
@ -68,7 +68,7 @@
|
|||
<label class="checkbox-inline"><input type="checkbox" name="fuelType" value="petrol_simple_98">Gasolina Simples 98</label><br>
|
||||
<label class="checkbox-inline"><input type="checkbox" name="fuelType" value="petrol_special_98">Gasolina Especial 98</label><br>
|
||||
<br><br>
|
||||
</div>
|
||||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@include('header')
|
||||
<div class="col-lg-12 text-center">
|
||||
<h1 class="center">Welcome, {{$name}}</h1>
|
||||
<h1 class="center">Bem-Vindo, {{$name}}</h1>
|
||||
<br><br>
|
||||
|
||||
<div class="btn-group">
|
||||
|
|
Loading…
Reference in New Issue