PHP Class Spatie\Menu\Laravel\Menu

Inheritance: extends Spatie\Menu\Menu, implements Illuminate\Contracts\Support\Htmlable, use trait Illuminate\Support\Traits\Macroable
Mostrar archivo Open project: spatie/laravel-menu Class Usage Examples

Public Methods

Method Description
action ( string $action, string $text, mixed $parameters = [], boolean $absolute = true )
actionIf ( boolean $condition, string $action, string $text, array $parameters = [], boolean $absolute = true )
actionIfCan ( string | array $authorization, string $action, string $text, array $parameters = [], boolean $absolute = true )
addIfCan ( string | array $authorization, Spatie\Menu\Item $item )
htmlIfCan ( string | array $authorization, string $html ) : Menu
linkIfCan ( string | array $authorization, string $url, string $text )
route ( string $name, string $text, mixed $parameters = [], boolean $absolute = true, Illuminate\Routing\Route | null $route = null )
routeIf ( boolean $condition, string $name, string $text, array $parameters = [], boolean $absolute = true, Illuminate\Routing\Route | null $route = null )
routeIfCan ( string | array $authorization, string $name, string $text, array $parameters = [], boolean $absolute = true, Illuminate\Routing\Route | null $route = null )
setActiveFromRequest ( string $requestRoot = '/' ) Set all relevant children active based on the current request's URL.
submenuIfCan ( string | array $authorization, callable | Menu | Spatie\Menu\Item $header, callable | Menu | null $menu = null )
toHtml ( ) : string
url ( string $path, string $text, mixed $parameters = [], boolean | null $secure = null )
urlIf ( boolean $condition, string $path, string $text, array $parameters = [], boolean | null $secure = null )
urlIfCan ( string | array $authorization, string $path, string $text, array $parameters = [], boolean | null $secure = null )
view ( string $name, array $data = [] )
viewIf ( $condition, string $name, array $data = null )
viewIfCan ( $authorization, string $name, array $data = null )

Protected Methods

Method Description
parseSubmenuIfCanArgs ( $authorization, $args ) : array

Method Details

action() public method

public action ( string $action, string $text, mixed $parameters = [], boolean $absolute = true )
$action string
$text string
$parameters mixed
$absolute boolean

actionIf() public method

public actionIf ( boolean $condition, string $action, string $text, array $parameters = [], boolean $absolute = true )
$condition boolean
$action string
$text string
$parameters array
$absolute boolean

actionIfCan() public method

public actionIfCan ( string | array $authorization, string $action, string $text, array $parameters = [], boolean $absolute = true )
$authorization string | array
$action string
$text string
$parameters array
$absolute boolean

addIfCan() public method

public addIfCan ( string | array $authorization, Spatie\Menu\Item $item )
$authorization string | array
$item Spatie\Menu\Item

htmlIfCan() public method

public htmlIfCan ( string | array $authorization, string $html ) : Menu
$authorization string | array
$html string
return Menu

linkIfCan() public method

public linkIfCan ( string | array $authorization, string $url, string $text )
$authorization string | array
$url string
$text string

parseSubmenuIfCanArgs() protected method

protected parseSubmenuIfCanArgs ( $authorization, $args ) : array
return array

route() public method

public route ( string $name, string $text, mixed $parameters = [], boolean $absolute = true, Illuminate\Routing\Route | null $route = null )
$name string
$text string
$parameters mixed
$absolute boolean
$route Illuminate\Routing\Route | null

routeIf() public method

public routeIf ( boolean $condition, string $name, string $text, array $parameters = [], boolean $absolute = true, Illuminate\Routing\Route | null $route = null )
$condition boolean
$name string
$text string
$parameters array
$absolute boolean
$route Illuminate\Routing\Route | null

routeIfCan() public method

public routeIfCan ( string | array $authorization, string $name, string $text, array $parameters = [], boolean $absolute = true, Illuminate\Routing\Route | null $route = null )
$authorization string | array
$name string
$text string
$parameters array
$absolute boolean
$route Illuminate\Routing\Route | null

setActiveFromRequest() public method

, /about, /contact => request to /about will set the about link active. en, /en/about, /en/contact => request to /en won't set /en active if the request root is set to /en.
public setActiveFromRequest ( string $requestRoot = '/' )
$requestRoot string If the link's URL is an exact match with the request root, the link won't be set active. This behavior is to avoid having home links active on every request.

submenuIfCan() public method

public submenuIfCan ( string | array $authorization, callable | Menu | Spatie\Menu\Item $header, callable | Menu | null $menu = null )
$authorization string | array
$header callable | Spatie\Menu\Menu | Spatie\Menu\Item
$menu callable | Spatie\Menu\Menu | null

toHtml() public method

public toHtml ( ) : string
return string

url() public method

public url ( string $path, string $text, mixed $parameters = [], boolean | null $secure = null )
$path string
$text string
$parameters mixed
$secure boolean | null

urlIf() public method

public urlIf ( boolean $condition, string $path, string $text, array $parameters = [], boolean | null $secure = null )
$condition boolean
$path string
$text string
$parameters array
$secure boolean | null

urlIfCan() public method

public urlIfCan ( string | array $authorization, string $path, string $text, array $parameters = [], boolean | null $secure = null )
$authorization string | array
$path string
$text string
$parameters array
$secure boolean | null

view() public method

public view ( string $name, array $data = [] )
$name string
$data array

viewIf() public method

public viewIf ( $condition, string $name, array $data = null )
$condition
$name string
$data array

viewIfCan() public method

public viewIfCan ( $authorization, string $name, array $data = null )
$name string
$data array