Reputation: 602
I have a function getLocation, that route is named "search.location" with for example the URL www.url.com/service/ny/slug. This shows a single location.
I now want to check, if the location is available. If the location with the given parameters is not available, I want, to call the route "search.servicecity" that has the parameters service and city. The URL is then www.url.com/service/ny/. How can I achieve to call the route with the parameters?
public function getLocation($servicename, $city, $slug){
$location = Location::where([
['slug','=',$slug],
['city','=',$city]
])->first();
if(count($location)>0){
return view('search.location')->with('servicename',$servicename)
->with('city',$city)->with('information','getLocation')
->with('slug',$slug)->with('location',$location);
}else{
//call search.servicecity with parameters $servicename and $city
}
}
Upvotes: 0
Views: 35