Illuminate\Routing\UrlGenerator::previous PHP Method

previous() public method

Get the URL for the previous request.
public previous ( mixed $fallback = false ) : string
$fallback mixed
return string
    public function previous($fallback = false)
    {
        $referrer = $this->request->headers->get('referer');
        $url = $referrer ? $this->to($referrer) : $this->getPreviousUrlFromSession();
        if ($url) {
            return $url;
        } elseif ($fallback) {
            return $this->to($fallback);
        } else {
            return $this->to('/');
        }
    }

Usage Example

 public function __construct(UrlGenerator $url)
 {
     $this->middleware('auth');
     $this->middleware('permission:dashboard')->only('getIndex');
     $this->prev = $url->previous();
     $this->module = 'admin';
 }
All Usage Examples Of Illuminate\Routing\UrlGenerator::previous