Download the PHP package kaishiyoku/laravel-menu without Composer
On this page you can find all versions of the php package kaishiyoku/laravel-menu. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kaishiyoku/laravel-menu
More information about kaishiyoku/laravel-menu
Files in kaishiyoku/laravel-menu
Package laravel-menu
Short Description Create menus for Laravel with css-class highlighting support
License MIT
Informations about the package laravel-menu
Laravel menus with automatic CSS highlighting
Table of contents
- Version info
- Minimum requirements
- General
- Important Information
- Installation
- Composer
- Laravel Configuration
- Usage
- Look & Feel
- License
- Author
Version info
Version 4 is a complete rework of the package. Thus breaking changes were introduced.
Minimum requirements
- PHP >=7.2.5
- Laravel ^6.0
General
This package helps defining and rendering menu structures in Laravel. The main feature is the CSS highlighting of the active page. The package is coupled to Laravel and can't be used standalone.
Important Information
Please note that your routes must be named.
Installation
Composer
Add to your composer.json by running .
Update your dependencies by running .
Laravel Configuration
The package supports Laravel auto-discovery but if you want you can add to the providers array
and to the aliases array in app/config/app.php.
Usage
- generate a new middleware by using
php artisan make:middleware Menus
- add
\App\Http\Middleware\Menus::class,
to the Http Kernel in$middlewareGroups
>'web'
- add your menus to the
handle()
method in your Menus middleware
Example \App\Http\Middleware\Menus.php:
Edited \App\Http\Kernel:
To display the configured menus you have to call the render function somewhere in your Blade template:
If the render() method is being called without parameters the default menu will be rendered. The menus must have unique names, otherwise an exception will be thrown.
The result would look like this:
If you have any issues feel free to open a ticket.
Sample
You can also use a condition whether the given menu entry should be rendered or not, example:
For dropdown links you can define multiple routes so that a given link will be highlighted when one of those routes is being visited. The first route will be the route to where the link goes:
Available methods
addClassNames(string|array $classNames)
adds CSS class names to the menu containerdisableXssFilter()
disables the integrated XSS filterlink(string $route, ?string $title = null, bool $strict = false)
- you can also use a comma-seperated $route list (eg.
entries.index,entries.create,entries.create
)
- you can also use a comma-seperated $route list (eg.
dropdown(string $title, DropdownContainer $dropdownContainer)
- The DropdownContainer class has the following methods available:
link(string $route, ?string $title = null)
header(string $title)
divider()
text(string $text)
content(string $content)
➡ Every container method can also be called with a condition. Only if this condition is true the container will be rendered. (eg. linkIf(bool $condition, string $route, ?string $title = null, bool $strict = false)
)
MenuContainer: linkIf
, dropdownIf
, textIf
, contentIf
DropdownContainer: linkIf
, headerIf
, dividerIf
Look & Feel
Currently the default look and feel is based on Bootstrap 4.
You can customize every Blade component by publishing them (php artisan vendor:publish --provider="Kaishiyoku\LaravelMenu\ServiceProvider"
)
License
MIT (https://github.com/Kaishiyoku/laravel-menu/blob/master/LICENSE)
Author
Twitter: @kaishiyoku
Website: https://andreas-wiedel.de
All versions of laravel-menu with dependencies
illuminate/support Version ^6.0|^7.0|^8.0
illuminate/contracts Version ^6.0|^7.0|^8.0
illuminate/routing Version ^6.0|^7.0|^8.0
illuminate/view Version ^6.0|^7.0|^8.0
cjstroud/classnames-php Version ^1.0
graham-campbell/security Version ^9.0