Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks
How to Get Current Url in Blade File Laravel

How to Get Current Url in Blade File Laravel ?

Aman Jain, October 27, 2022March 16, 2024

Sometimes in our application we want to Get Current Url in Blade file Laravel because we want to add specific conditions to show the data on behalf of current url. It can be complete url, route name and query params too so that we can fetch the data accordingly and show to user on basis of conditions in our view or controller.

We can easily get current url in blade laravel 5, laravel 6, laravel 7, laravel 8 and laravel 9 application and all example will work in all versions. Majorly we will use url helper and facade function of laravel.

There is multiple ways to find the current url , route name and all information of route with query params in laravel and they are as follow

Get Current URL using url Helper

We will learn to find the query params and current url in this article and also learn to access each of query params by converting them into array so that we can easily parse and use in our view and controller so let’s start the tutorial with methods

Method 1 : Get Current URL using url Helper

To get the url using url helper we need to call as follow

$currentURL = url()->current();

//Or FACADE

$currentURL = /URL::current();

Method 2 : Get Current URL With Query Params

In this example we will get all query params as well with help of full method of url helper as follow

$urlWithQuery = url()->full();

//Or FACADE

$currentURL = /URL::full();

Method 3 : Get Current URL With Request Class

In this example we will get all query params as well with help of full method of request class as follow

$urlWithQuery = $request->full();

@if(\Request::url() === 'your url here')
    // code
@endif

or we can also get query parameters as follow

request()->get("query_params1");

or to match the path

if (Request::is('admin/*'))
{
    // code
}

How to get route name and info in laravel ?

Sometimes we also need to get the route name of current request so we can get as follow

$route = Route::current()->getName();

$name = Route::currentRouteName();

$action = Route::currentRouteAction();

Related

Php Laravel Laravel 9 bladecurrentlaravelrequesturl

Post navigation

Previous post
Next post

Related Posts

Php How to delete column in laravel migration ?

How to delete column in laravel migration ?

February 17, 2022February 26, 2024

Deleting column to existing table are easy as creating a new table and adding columns to it. To delete column in laravel migration to existing table we can use the same method we used in create migrations . Major difference between creating new table and updating new table is Schema::create…

Read More
Php Simplest Way to Install Laravel 10

Simplest Way to Install Laravel 10

March 12, 2023March 16, 2024

Laravel is most popular framework of PHP. It provides lots of in-build tools and library to build the web application. laravel community has working quite hard to make the laravel most efficient and secured framework for web developers that’s why most of the websites are built with laravel as backend….

Read More
Php Integrate Google Map with Marker in Laravel

Integrate Google Map with Marker in Laravel

August 28, 2022March 16, 2024

In this article we will learn to integrate google map with marker in laravel. Google maps are used to share the location or indicate the location of business and any user. In our application we want to show the exact location so in that case google maps are most optimal…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • The Resilience of Nature: How Forests Recover After Fires
  • Understanding Laravel Cookie Consent for GDPR Compliance
  • Understanding High Vulnerabilities: A Critical Overview of the Week of May 12, 2025
  • Installing a LAMP Stack on Ubuntu: A Comprehensive Guide
  • Understanding High Vulnerabilities: A Deep Dive into Recent Security Concerns
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version