V4n1ll4
V4n1ll4

Reputation: 6099

Get the first directory path from url in Laravel 5.1

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?

Upvotes: 1

Views: 2352

Answers (1)

Tanvir
Tanvir

Reputation: 1695

You can use uri segment.

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

Hope it will help.Thanks

Upvotes: 7

Related Questions