How to get Url Segment in laravel?

you can get current url segment using Request facade.

File name : index.php

@section('content')
{{ Request::segment(1) }}
@endsection

class Active or not (Navigation menu Active or Not)

class="{{ Request::segment(1)=='category'?'active':NULL }}"

How to get all segment of url

$current_uri = request()->segments();

//get segment 0
$segment_users = request()->segment(0); //returns 'users'
//get segment 1
$segment_posts = request()->segment(1); //returns 'posts'





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here


Ittutorial