Download the PHP package radiatecode/laravel-navbar without Composer
On this page you can find all versions of the php package radiatecode/laravel-navbar. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download radiatecode/laravel-navbar
More information about radiatecode/laravel-navbar
Files in radiatecode/laravel-navbar
Package laravel-navbar
Short Description Laravel package to generate menus
License MIT
Informations about the package laravel-navbar
Laravel Navbar
This package generates navigation/navbar for laravel application. The package also provide a build in html navigation UI, it also allows you to build your own custom navigation UI.
Sample & Usages
Note: You can(should) generate the navbar in the View Composer
Navbar In View Composer Example
In _left_nav partials
Output
Requirements
- PHP >= 7.1
- Laravel 5.7|6.x|7.x|8.x|9.x
- JQuery [Optional for custom navbar UI styling]
- Bootstrap [Optional for custom navbar UI styling]
Installation
You can install the package via composer:
composer require radiatecode/laravel-navbar
Publish config file (optional)
php artisan vendor:publish --provider="RadiateCode\LaravelNavbar\NavbarServiceProvider" --tag="navbar-config"
Usage
Nav available methods
1. Header : it is use to group certain nav items
Syntax:
header(string $name, Closure $closure, array $attributes = [])
: 1st arg is the name of the header, 2nd arg is a closure to add nav items under the header, 3rd is for any extra attributes (ex: icon, class etc.)
2. Add: add nav items
Syntax:
add(string $title, string $url, ?array $attributes = null, ?callable $children = null)
: 1st arg name of the nav item, 2nd arg is the nav url, 3rd is for any extra attributes (ex: nav icon, classes), 4th arg is for if you want to add children nav.
3. Add If: Conditionally add nav
Syntax:
addIf($condition, string $title, string $url, array $attributes = [], ?callable $configure = null)
: 1st arg is the condition bool or closure return bool, 2nd name of the nav, 3rd nav url, 4th extra attributes, 5th a closure for adding children nav.
4. Chidlren nav: you can add children navs
You have already noticed how we added children nav. We can also conditionally add children nav
5. Render: and the render method to get the array of nav items
Navbar UI Builder
Laravel-Navbar
provide a built in navbar UI builder so that you can easily integrate the UI with your app.
Note: You can built your own custom Navbar UI by defining custom Navbar Presenter. Or, you can comes up with your own approch to show navbar.
Example: see the view composer example
Methods
Available methods of the builder
navs(array $navItems)
: generated nav itemsrender()
: Render the html-
navActiveScript()
: Nav active script usefull if you want to active the current nav item in the front-end by Js(JQuery). It has another benefit, if you cache the generated navbar this script will help you to active your current nav because the back-end active function only active once before cache, after cached it always show that same active nav. So it is recommended if you want to cache your navbar you should disable back-endnav-active
from the Config and use this script in the front-end.Or, you can add it to you script partials
Navbar Presenter
Navbar presenter is nothing but a class which contain some functionality to generate navbar html. Under the hood the Navbar Config
Config
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-navbar with dependencies
ext-json Version *