Support the ongoing development of Laravel.io →
Requests Input

Hi,

I am new to Laravel and I am trying to get my head around routing.

I have set up a controller and a resource in the routes file:

Route::resource('placements', 'PlacementController');

I have this working to query the database and display everything but what I would like to do is manipulate the sidebar menu depending on which view (index, create, show, edit, update, destroy) is loaded.

I have a sidebar.blade.php file that gets included but I can't work out what to use with the IF statement so that it recognises the different RESTful URLs e.g. /placements/1 or placements/1/edit etc.

How do I change this to recognise the id too ?

@if (Request::path() == 'placements')

@endif

Thanks

Last updated 2 years ago.
0

Maybe Request::segment will help you?

Last updated 9 years ago.
0

View composer might be a better approach?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

whiskers whiskers Joined 16 Jul 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.