Skip to content

Instantly share code, notes, and snippets.

@aytacmalkoc
Last active June 27, 2024 23:40
Show Gist options
  • Save aytacmalkoc/a125dd5771a17e2c1c1e9aa34496f252 to your computer and use it in GitHub Desktop.
Save aytacmalkoc/a125dd5771a17e2c1c1e9aa34496f252 to your computer and use it in GitHub Desktop.
Laravel route_is helper
<?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