How to get url path one level below in laravel?

by filiberto , in category: PHP Frameworks , 7 months ago

How to get url path one level below in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by rollin , 7 months ago

@filiberto 

You can get the URL path one level below in Laravel by using the url()->current() function and then applying dirname() function to it.


Here is an example code snippet:

1
2
$currentUrl = url()->current();
$parentUrl = dirname($currentUrl);


This code will get the current URL and then extract the parent URL path by going one level below.