-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.php
42 lines (36 loc) · 998 Bytes
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
use Arcanedev\LaravelActive\Contracts\Active;
if ( ! function_exists('active')) {
/**
* Get the active class if the current route/path matches with the haystack.
*
* @param string|array $routes
* @param string|null $class
* @param string|null $fallback
*
* @return \Arcanedev\LaravelActive\Contracts\Active|string|null
*/
function active($routes = [], $class = null, $fallback = null)
{
/** @var \Arcanedev\LaravelActive\Contracts\Active $active */
$active = app(Active::class);
if (empty($routes)) {
return $active;
}
return $active->active($routes, $class, $fallback);
}
}
if ( ! function_exists('is_active')) {
/**
* Check if any of the given routes are active.
*
* @param array|string $routes
*
* @return bool
*/
function is_active($routes): bool
{
return active()->is($routes);
}
}