Completed
Push — master ( 7f32b3...b1a367 )
by Sebastian
03:53
created

Menu::url()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 4
1
<?php
2
3
namespace Spatie\Menu\Laravel;
4
5
use Illuminate\Support\Traits\Macroable;
6
use Spatie\Menu\Menu as BaseMenu;
7
8
class Menu extends BaseMenu
9
{
10
    use Macroable;
11
12
    /**
13
     * Set all relevant children active based on the current request's URL.
14
     *
15
     * /, /about, /contact => request to /about will set the about link active.
16
     *
17
     * /en, /en/about, /en/contact => request to /en won't set /en active if the request root
18
     *                                is set to /en.
19
     *
20
     * @param string $requestRoot If the link's URL is an exact match with the request root, the
21
     *                            link won't be set active. This behavior is to avoid having home
22
     *                            links active on every request.
23
     *
24
     * @return $this
25
     */
26
    public function setActiveFromRequest(string $requestRoot = '')
27
    {
28
        return $this->setActive(app('request')->url(), $requestRoot);
29
    }
30
31
    /**
32
     * @param string $path
33
     * @param string $text
34
     * @param array $parameters
35
     * @param bool|null $secure
36
     *
37
     * @return $this
38
     */
39
    public function url(string $path, string $text, $parameters = [], $secure = null)
40
    {
41
        return Link::url($path, $text, $parameters, $secure);
42
    }
43
44
    /**
45
     * @param string $action
46
     * @param string $text
47
     * @param array $parameters
48
     * @param bool $absolute
49
     *
50
     * @return $this
51
     */
52
    public function action(string $action, string $text, $parameters = [], $absolute = true)
53
    {
54
        return Link::action($action, $text, $parameters, $absolute);
55
    }
56
57
    /**
58
     * @param string $name
59
     * @param string $text
60
     * @param array $parameters
61
     * @param bool $absolute
62
     * @param \Illuminate\Routing\Route|null $route
63
     *
64
     * @return $this
65
     */
66
    public function route(string $name, string $text, $parameters = [], $absolute = true, $route = null)
67
    {
68
        return Link::route($name, $text, $parameters, $absolute, $route);
69
    }
70
}
71