diff --git a/readme.md b/readme.md index 9802da6..071b4a0 100644 --- a/readme.md +++ b/readme.md @@ -86,9 +86,9 @@ Using boolean `true` or `false` is convenient if you need to display some conten ## API -There are two ways of using Ekko in your application, by using a facade `Ekko::isActiveURL('/about')` or by using a helper function `isActiveURL('/about')`. +There are two ways of using Ekko in your application, by using a facade `Ekko::isActiveURL('/about')` or by using a helper function `isActiveURL('/about')` or `is_active_route('/about')`. -### isActiveRoute +### isActiveRoute, is_active_route Compares given route name with current route name. @@ -96,6 +96,10 @@ Compares given route name with current route name. isActiveRoute($routeName, $output = "active") ``` +```php +is_active_route($routeName, $output = "active") +``` + **Examples:** If the current route is `home`, function `isActiveRoute('home')` would return *string* `active`. @@ -104,7 +108,7 @@ _The `*` wildcard can be used for resource routes._ Function `isActiveRoute('user.*')` would return *string* `active` for any current route which begins with `user`. -### isActiveURL +### isActiveURL, is_active_url Compares given URL path with current URL path. @@ -112,11 +116,15 @@ Compares given URL path with current URL path. isActiveURL($url, $output = "active") ``` +```php +is_active_url($url, $output = "active") +``` + **Examples:** If the current URL path is `/about`, function `isActiveURL('/about')` would return *string* `active`. -### isActiveMatch +### isActiveMatch, is_active_match Detects if the given string is found in the current URL. @@ -124,11 +132,15 @@ Detects if the given string is found in the current URL. isActiveMatch($string, $output = "active") ``` +```php +is_active_match($string, $output = "active") +``` + **Examples:** If the current URL path is `/about` or `/insideout`, function `isActiveMatch('out')` would return *string* `active`. -### areActiveRoutes +### areActiveRoutes, are_active_routes Compares given array of route names with current route name. @@ -136,6 +148,10 @@ Compares given array of route names with current route name. areActiveRoutes(array $routeNames, $output = "active") ``` +```php +are_active_routes(array $routeNames, $output = "active") +``` + **Examples:** If the current route is `product.index` or `product.show`, function `areActiveRoutes(['product.index', 'product.show'])` would return *string* `active`. @@ -144,7 +160,7 @@ _The `*` wildcard can be used for resource routes, including nested routes._ Function `areActiveRoutes(['user.*', 'product.*'])` would return *string* `active` for any current route which begins with `user` or `product`. -### areActiveURLs +### areActiveURLs, are_active_urls Compares given array of URL paths with current URL path. @@ -152,6 +168,10 @@ Compares given array of URL paths with current URL path. areActiveURLs(array $urls, $output = "active") ``` +```php +are_active_urls(array $urls, $output = "active") +``` + **Examples:** If the current URL path is `/product` or `/product/create`, function `areActiveURLs(['/product', '/product/create'])` would return *string* `active`. diff --git a/src/Laravelista/Ekko/helpers.php b/src/Laravelista/Ekko/helpers.php index c92076a..e97ff29 100644 --- a/src/Laravelista/Ekko/helpers.php +++ b/src/Laravelista/Ekko/helpers.php @@ -15,6 +15,19 @@ function isActiveRoute($routeName, $output = "active") } } +if (!function_exists('is_active_route')) { + /** + * @param $routeName + * @param string $output + * + * @return string + */ + function is_active_route($routeName, $output = "active") + { + return isActiveRoute($routeName, $output); + } +} + if (!function_exists('isActiveURL')) { /** * @param $url @@ -28,6 +41,19 @@ function isActiveURL($url, $output = "active") } } +if (!function_exists('is_active_url')) { + /** + * @param $url + * @param string $output + * + * @return string + */ + function is_active_url($url, $output = "active") + { + return isActiveURL($url, $output); + } +} + if (!function_exists('isActiveMatch')) { /** * @param $string @@ -41,6 +67,19 @@ function isActiveMatch($string, $output = "active") } } +if (!function_exists('is_active_match')) { + /** + * @param $string + * @param string $output + * + * @return string + */ + function is_active_match($string, $output = "active") + { + return isActiveMatch($string, $output); + } +} + if (!function_exists('areActiveRoutes')) { /** * @param array $routeNames @@ -54,6 +93,19 @@ function areActiveRoutes(array $routeNames, $output = "active") } } +if (!function_exists('are_active_routes')) { + /** + * @param array $routeNames + * @param string $output + * + * @return string + */ + function are_active_routes(array $routeNames, $output = "active") + { + return areActiveRoutes($routeNames, $output); + } +} + if (!function_exists('areActiveURLs')) { /** * @param array $urls @@ -66,3 +118,16 @@ function areActiveURLs(array $urls, $output = "active") return app(Ekko::class)->areActiveURLs($urls, $output); } } + +if (!function_exists('are_active_urls')) { + /** + * @param array $urls + * @param string $output + * + * @return string + */ + function are_active_urls(array $urls, $output = "active") + { + return areActiveURLs($urls, $output); + } +}