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

Laravel Laravel Audit Integration

Exploring Laravel Audit Integration: Ensuring Data Security and Accountability

November 9, 2023March 16, 2024

In today’s digital age, data security and accountability are of utmost importance and Laravel Audit most important to keep the records of each changes. Organizations need to keep a close eye on who accesses, modifies, or deletes sensitive information within their applications. Laravel, a popular PHP framework, has a powerful…

Read More
Php How to Upload image with preview in Laravel 8 with example

How to Upload image with preview in Laravel 8 with example ?

May 14, 2022August 20, 2022

Upload image with preview in laravel or for any website can be basic requirement like set up a profile picture to providing the documents. Laravel provides robust functionality to upload and process the image with security. Laravel simply use Request file method to access the uploaded file and then we…

Read More
Php How to Create Rest APIs in Laravel

How to Create Rest APIs in Laravel ?

July 4, 2022August 2, 2022

Rest APIs are used to create the communication between client and server and in this application we will learn to create rest apis in laravel. Rest API is a architectural style which same as both server and client end so any client can consume the apis since it has industry…

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