Ad

How To Get Current Route In Laravel Blade?

- 1 answer

I want to check if the current route isn't equal to a specific route in laravel view. How can I do that in Blade ?

my attempt:

 @if(Route::current() != Route('places.show'))
     <td><a target="_blank" rel="nofollow noreferrer" href="/admin/places/display/{{$order->place->id}}">{{ $order->place->name }}</a></td>
 @endif
Ad

Answer

Laravel Routes has method to get it.

To get current route name:

Illuminate\Support\Facades\Route::currentRouteName();

To check the current route is a matching route:

Illuminate\Support\Facades\Route::is('routename');
Ad
source: stackoverflow.com
Ad