Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eddy1992's avatar

how to hide a div on a condition

Hi I have a piece of view and I want to hide a particular div on certain routes but I am not sure how would I do it.
my div

//if routes are these (catalog, etc etc...... ) then do not show this div
 <div class="top_left_new_add" data-toggle="modal" data-target="#pincodeModal">
                    <span class="top-pincode-icon"></span>
                        <div class="non_select_top">
                            <span>
                                    @if(Cookie::has('city'))
                                        @if(Cookie::has('locality'))
                                            {{-- @if(Cookie::has('user_pincode')) --}}
                                                {{-- {{Cookie::get('locality')." - ".Cookie::get('user_pincode')." ".Cookie::get('city')}} --}}
                                            {{-- @else --}}
                                                {{Cookie::get('locality')." ".Cookie::get('city')}}
                                            {{-- @endif --}}
                                        @else
                                            {{Cookie::get('city')}}
                                        @endif
                                    @else                       
                                        Ballabgarh, Faridabad
                                    @endif
                            </span><i></i>
                        </div>
                    <span class="pincode">
                        <a href="javascript:void(0)" class="change-pincode">&nbsp;</a>
                    </span>

                </div>

How would I add this logic in the blade ?

0 likes
5 replies
eddy1992's avatar

@bobbybouwmann how would I tell that when user comes to a ceratin route say cart/proceed-to-pay this div should hide ?

Force's avatar
@if(\Request::route()->getName() != "routename")
    <div>Route =! routename</div>
@else
    <div>Route == routename</div>
@endif 
bobbybouwmann's avatar

You can also do something like this

@if (Request::is('cart/proceed-to-pay')

// Or everything that starts with "cart/"
@if (Request::is('cart/*') 
2 likes

Please or to participate in this conversation.