Commit 50464caa authored by Sylvain's avatar Sylvain

Ajout de la fonction current_parent_route_belongs()

parent ff168966
......@@ -56,6 +56,7 @@ Laravel 5.8 uses autoload files, so doesn't require you to manually add the Serv
- [current_query_to_array](#current_query_to_array)
- [current_query_to_string](#current_query_to_string)
- [current_route_belongs](#current_route_belongs)
- [current_parent_route_belongs](#current_parent_route_belongs)
**_Divers_**
- [calc_increase_percent](#calc_increase_percent)
......@@ -236,6 +237,13 @@ $belongs = current_route_belongs('page.list');
// false
```
#### `current_parent_route_belongs()`
La fonction `current_parent_route_belongs()` vérifie si l'url courante appartient (enfant compris) à une route parente (segment -1)
```php
$belongs = current_parent_route_belongs('page.category.list');
// false
```
#### `calc_increase_percent()`
La fonction `calc_increase_percent()` calcul le pourcentage d'accroissement entre 2 valeurs
```php
......
......@@ -43,3 +43,19 @@ if (! function_exists('current_route_belongs')) {
return Request::is($uri . '*');
}
}
if (! function_exists('current_parent_route_belongs')) {
/**
* Vérifie si l'url courante appartient (enfant compris) à une route parent (segment -1)
* @param string La route à tester
* @return string
*/
function current_parent_route_belongs($route_name) : string
{
$route = route($route_name, [], false);
preg_replace('/\/([^\/]*\/?)$/', '', $route);
$uri = trim($route, '/');
return Request::is($uri . '*');
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment