Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
Helpers
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Modulus
Helpers
Commits
50464caa
Commit
50464caa
authored
Nov 04, 2020
by
Sylvain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout de la fonction current_parent_route_belongs()
parent
ff168966
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
README.md
README.md
+8
-0
src/url.php
src/url.php
+16
-0
No files found.
README.md
View file @
50464caa
...
...
@@ -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
...
...
src/url.php
View file @
50464caa
...
...
@@ -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
.
'*'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment