Laravel重定向到其他路线

时间:2017-11-28 21:48:36

标签: php laravel-5.5

我有一个函数getLocation,该路由名为“search.location”,例如URL www.url.com/service/ny/slug。这显示了一个位置。

我现在想检查,如果位置可用。如果具有给定参数的位置不可用,我想要调用具有参数service和city的路径“search.servicecity”。该URL是www.url.com/service/ny/。如何使用参数调用路径?

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
  }
}

0 个答案:

没有答案