Ad

Get The First Directory Path From Url In Laravel 5.1

- 1 answer

I want to be able to get the first path directory from a URL in Laravel 5.1. For example, take a look at the following url:

http://mydomain.co.uk/supervisor/add

From the above url, I want to return /supervisor

Does anyone know how I can achieve this?

Ad

Answer

You can use uri segment.

$segment = Request::segment(1);
dd($segment);

Hope it will help.Thanks

Ad
source: stackoverflow.com
Ad