i have a section in my website with a search google maps api.
now i have this: when i enter to domain.com/fields?address_latitude=-34.5396425&address_longitude=-58.705582&dif=1 it show all places arround in 1km... It work perfect.
public function index(Request $request) {
if ($request)
{
$query=trim($request->get('address_latitude'));
$query2=trim($request->get('address_longitude'));
$query3=trim($request->get('dif'));
$latitude = $query;
$longitude = $query2;
$dif = $query3;
$shops = DB::table("shops");
$shops = $shops->select("*", DB::raw("6371 * acos(cos(radians(" . $latitude . "))
* cos(radians(latitude)) * cos(radians(longitude) - radians(" . $longitude . "))
+ sin(radians(" .$latitude. ")) * sin(radians(latitude))) AS distance"));
$shops = $shops->having('distance', '<', $dif);
$shops = $shops->orderBy('distance', 'asc');
$shops = $shops->get();
return view('land.fields',["shops"=>$shops,"address_latitude"=>$query,"address_longitude"=>$query2,"dif"=>$query3]);
}
}
but i need apply a IF in case of i enter in domain.com/fields i need here display all my places... i have the code of this... but i have problem to make the "IF"
Any can help me please?
Aucun commentaire:
Enregistrer un commentaire