In Laravel provides a URL facade that way we can get the current URL anywhere in laravel app, so we will see the example of current() URL facade.
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\URL;
$current_url = url()->current();
dd($current_url);
OR
$current_url = url()->full();
dd($current_url);
OR
$current_url = URL::current();
dd($current_url);
OR
$current_url = URL::full();
dd($current_url);
OR
$current_url = $request->url();
dd($current_url);
OR
$route = Route::current()->getName();
dd($route);
for Previouse URL
$url = url()->previous();
dd($url);