Last active
June 27, 2024 23:40
-
-
Save aytacmalkoc/a125dd5771a17e2c1c1e9aa34496f252 to your computer and use it in GitHub Desktop.
Laravel route_is helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('route_is')) { | |
function route_is(string|array $routeNames): bool | |
{ | |
$currentRoute = \Illuminate\Support\Facades\Route::currentRouteName(); | |
$routeNames = (array) $routeNames; | |
return collect($routeNames)->contains(fn($routeName) => \Illuminate\Support\Str::is($routeName, $currentRoute)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment