Get Current Url Parameter using Laravel

Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects

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.

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 :

Read Also:  Laravel 6 Get All query string parameters

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.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

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