leecraigjeffries / laravel-sidebar
Laravel Sidebar
dev-master
2019-10-28 17:20 UTC
Requires
- php: >=7.1.3
- facade/ignition-contracts: ^1.0
- illuminate/support: ^5.6|^6.0
- illuminate/view: ^5.6|^6.0
This package is auto-updated.
Last update: 2024-04-29 04:09:39 UTC
README
1. Install Laravel Sidebar
Run this at the command line:
composer require leecraigjeffries/laravel-sidebar
This will update composer.json
and install the package into the vendor/
directory.
2. Define your sidebars
Create a file called routes/sidebar.php
that looks like this:
<?php /// Parameters: sidebar name, path to view Sidebar::register('default', 'vendor.sidebar.default', static function ($sidebar) { // Text, name of route or href, extra properties $sidebar->push('Section', '#section', ['icon' => '<i class="far fa-flag"></i>'], static function ($group) { $group->push('Heading', '', null, static function ($heading) { $heading->push('Link', '#link', null, static function($link){ // Links can be embedded endlessly $link->push('Sub Link', '#sublink')->setActive(); }); }); }); });
3. Render your Sidebar in Blade View
{!! Sidebar::render('default') !!}
The $link
variable will be used in the chosen view
4. Active Links
Active links are links that have the same route name as that which is currently in use
By using $link->getHasActiveChild()
the view will know that the link has a child embedded that is active
To see whether a link is active you can use $link->getActive()
5. Publishing the SASS and view file
By running php artisan vendor:publish
you can publish example view and SASS files