Get Current Url Parameter using Laravel

Today, We want to share with you Get Current Url Parameter using Laravel.In this post we will show you laravel get url parameters in middleware, hear for get value of URL parameters into Controller (Laravel) we will give you demo and example for implement.In this post, we will learn about Laravel Request getting current path with query string with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Get Current Url Parameter using Laravel

There are the Following The simple About Get Current Url Parameter using Laravel Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.7 get current url with parameters, so the laravel get url parameters in view for this example is following below.

Get Current URL with Parameters:

using Request Facade

$GetcurrentURL = \Request::fullUrl();

dd($GetcurrentURL);

Get Current URL without Parameters:

using URL Facade

$GetcurrentURL = \URL::current();

dd($GetcurrentURL);

//OR Second Way

$GetcurrentURL = \Request::url();

dd($GetcurrentURL);

Get Only Parameters:

using $request Object

//www.myLivedomainname.com/post/list?page=2

$parameters = \Request::segment(3);

dd($parameters);

Laravel – get current URL in controller or view?

$GetcurrentURL = URL::current();
dd($GetcurrentURL);

Laravel Get Current URL in a Blade View

Get the current path

@if (Request::path() == '/product-title')
    // your condition Source Code
@endif

Compare the current URL to a pattern

@if (Request::is('product/*'))
    // your condition Source Code
@endif

Get only a segment of the current URL

// Returns true for yourdomainname.com/product/post and false for yourdomainname.com/product/edit
@if (Request::segment(2) == 'post')
    // your condition Source Code
@endif

Get the URL without query string

@if (Request::url() == 'some string')
    // your condition Source Code
@endforeach

Get the full URL, including query string

@if (str_contains(Request::fullUrl(), 'product-list'))
    // your condition Source Code
@endif

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Get Current Url Parameter using Laravel.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Laravel 5.7 Get Current Page URL path
  2.   laravel get all query string
  3.   Laravel 6 Get All query string parameters
  4.   Send, Get data redirect route with parameters in laravel
  5.   Laravel JSON Encode Decode Handling
  6.   Laravel 6 WhereNotIn Query Example
  7.   PHP Get Query String Parameters using Laravel
  8.   Automatically Refresh/Reload Page using VueJS Example
  9.   PHP jQuery AJAX Live check email Availability
  10.   Angularjs Store in Localstorage - ngStorage

Leave a Reply

Your email address will not be published. Required fields are marked *