Last active
January 12, 2025 06:12
-
-
Save aytacmalkoc/a125dd5771a17e2c1c1e9aa34496f252 to your computer and use it in GitHub Desktop.
Laravel helper functions
This file contains hidden or 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)); | |
} | |
} | |
if (!function_exists('route_with_query')) { | |
function route_with_query($name, $parameters = [], $absolute = true): string | |
{ | |
return route($name, [request()->getQueryString(), ...$parameters], $absolute); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment