1Request::url(), Request::fullUrl(),
2Request::path(), Request::is() and Request::segment().
3
4 @if (Request::path() == '/post-title')
5 // Do something
6@endif
7
8 @if (Request::is('admin/*'))
9 // Do something
10@endif
11 // Returns true for example.com/admin/post and false for example.com/admin/edit
12@if (Request::segment(2) == 'post')
13 // Do something
14@endif
15
16 @if (Request::url() == 'some string')
17 // Do something
18@endforeach
19
20 @if (str_contains(Request::fullUrl(), 'some-string'))
21 // Do something
22@endif
23
24$currentURL = url()->current();
25dd($currentURL);
26
27$currentURL = url()->full();
28dd($currentURL);
29
30//current() with Facade
31$currentURL = URL::current();
32dd($currentURL);
33
34// Get Previous URL in Laravel:
35$url = url()->previous();
36dd($url);
37
38//Get Current Route in Laravel:
39$route = Route::current()->getName();
40dd($route);
41
42
43