Ad

Laravel, Blade Show Something If Multiple Routes Exist

- 1 answer

I want to show edit and delete button if current route names are not (multiple routes names) I don't know if there is any other way to do this because the current I use is very complex

  @if ((Route::current()->getName() != ('checkout') ) AND (Route::current()->getName() != ('checkout.payment') ) AND (Route::current()->getName() != ('checkout.addpayment') ) AND (Route::current()->getName() != ('houseaccountform') )AND (Route::current()->getName() != ('ajaxdata.tips') ))
  <span class="count-number float-right">
    <a target="_blank" rel="nofollow noreferrer" href="javascript:void(0);" data-id="{{$cartContent->options->product_id}}" data-editproductid="{{$cartContent->rowId}}" class="Item_root btn btn-outline-secondary  btn-sm left dec editorder-edit"><i class="icofont-edit" style="font-size: 20px;"></i></a>
    <button class="btn btn-outline-secondary  btn-sm left dec order-item__remove" data-id="{{$cartContent->rowId}}">
      <svg class="i-close" aria-labelledby="close-title" viewBox="0 0 32 32" width="32" height="32" role="img">
        <title id="close-title">Delete</title>
        <path fill="currentColor" d="M16 13.825l8.627-8.627 2.175 2.175-8.627 8.627 8.627 8.627-2.175 2.175-8.627-8.627-8.627 8.627-2.175-2.175 8.627-8.627-8.627-8.627 2.175-2.175z">
        </path>
      </svg>
    </button>
  </span>
  @endif
Ad

Answer

You could use the in array PHP method

https://www.php.net/manual/en/function.in-array.php

@if(!in_array(Route::current()->getName(), ['checkout', 'checkout.payment']))

Include the rest of the possible routes.

Ad
source: stackoverflow.com
Ad