permafrost-dev/laravel-current-route

该包已被废弃,不再维护。未建议替代包。

获取当前路由信息的辅助函数

1.0.5 2020-07-22 15:50 UTC

This package is auto-updated.

Last update: 2021-07-23 19:33:46 UTC


README

Laravel 当前路由

用于获取 Laravel 中当前路由信息的辅助函数和类。

GitHub tag (latest SemVer)

安装

您可以通过 composer 安装此包

composer require permafrost-dev/laravel-current-route

辅助函数

// Return a Laravel Route object for the current route.
function current_route();

// Return a class containing information about the current route.
function current_route_info();

// Return the action for the current route.
function current_route_action();

// Return true if one of the specified wildcard patterns matches the name of the current route.
function current_route_matches($patterns);

// Return the name for the current route.
function current_route_name();

// Returns true if $name matches the name of the current route.
function current_route_named($name);

使用方法

进行中

示例

使用 current_route_named() 在 blade 模板中生成条件 CSS 类

<a class="{{ current_route_named('dashboard') ? 'active' : 'inactive' }}"
    href="{{ route('dashboard') }}">Dashboard
</a>

测试

$ vendor/bin/phpunit

许可

MIT 许可证 (MIT)。请参阅许可文件以获取更多信息。