如何在Laravel Blade中获取当前路由?

12 浏览
0 Comments

如何在Laravel Blade中获取当前路由?

这个问题已经有答案了

在Laravel 4中如何在@if语句(Blade模板)中获取当前的URL?

我想在laravel的视图中检查当前路由是否与特定路由不相等。在Blade中我该如何做呢?

我尝试过:

 @if(Route::current() != Route('places.show')){{ $order->place->name }}

@endif

admin 更改状态以发布 2023年5月24日
0
0 Comments

您可以在路由类上调用currentRouteName。

Route::currentRouteName();

别忘了使用该类:

use Illuminate\Support\Facades\Route;

检查当前路由:

Illuminate\Support\Facades\Route::is('routename');

0
0 Comments

Laravel路由有获取当前路由的方法。

要获取当前路由名称:

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

要检查当前路由是否匹配:

Illuminate\Support\Facades\Route::is('routename');

0