Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how get url in laravel

// Get the current URL without the query string...
echo url()->current();

// Get the current URL including the query string...
echo url()->full();

// Get the full URL for the previous request...
echo url()->previous();
Comment

how to get current url path in laravel

// Full URL with query string
print $request->fullUrl(); // http://127.0.0.1:8000/sometext?city=hyd

// Get the path part of the URL 
print $request->path(); // sometext

// Root (protocol and domain) part of the URL)
print $request->root(); //http://127.0.0.1:8000

//Get the full URL for the previous request
print url()->previous();

//tested on Laravel 5.6

//OR 

use IlluminateSupportFacadesURL;
 
print URL::current();
Comment

How to get current url in laravel

//get current url
use IlluminateSupportFacadesRoute;
Route::getFacadeRoot()->current()->uri();
//get current full url
$url = url()->current();
Comment

Laravel get url

Example 1: current() with Helper

$currentURL = url()->current();
  
dd($currentURL);
Example 2: full() with Helper(with query string parameters)

$currentURL = url()->full();
    
dd($currentURL);
Example 3: current() with Facade

$currentURL = URL::current();
    
dd($currentURL);
Example 4: full() with Facade(with query string parameters)

$currentURL = URL::full();
    
dd($currentURL);
Example 5: using Request

$currentURL = Request::url();
  
dd($currentURL);
Get Previous URL in Laravel:

$url = url()->previous();
  
dd($url);
Get Current Route in Laravel:


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

laravel current url

use IlluminateSupportFacadesURL;
 
echo URL::current();
Comment

PREVIOUS NEXT
Code Example
Php :: laravel custom attributes 
Php :: php run localhost 
Php :: how to backup laravel project 
Php :: wp logs 
Php :: laravel new date 
Php :: https redirect in htacess for php laravel 
Php :: php get url 
Php :: count words in string php 
Php :: upload webp to wordpress 
Php :: get words after string in in php 
Php :: force delete soft delete laravel 
Php :: php copy 
Php :: How to validate a file type in laravel 
Php :: wordpress featured image show 
Php :: php declare strict_types 
Php :: phpcs 
Php :: add log in laravel 8 
Php :: random digit with seed php 
Php :: php loop object 
Php :: laravel image ratio validation 
Php :: auth.php Class "AppUser" not found 
Php :: phpcs ignore line warning 
Php :: php constant array 
Php :: php get parameter 
Php :: how to add values to an array in laravel 
Php :: date diff php 
Php :: install php 7.3 ubuntu 
Php :: How do I convert a string to a number in PHP? 
Php :: why do we use php exceptions 
Php :: how to send data from one website to another in php 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =