Skip to content

Instantly share code, notes, and snippets.

@JellyBool
Created November 24, 2016 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JellyBool/341ed015f487bd5dca9c34f9d39ca368 to your computer and use it in GitHub Desktop.
Save JellyBool/341ed015f487bd5dca9c34f9d39ca368 to your computer and use it in GitHub Desktop.
laravel menu
// Sidebar.php
<?php
namespace App;
use Menu;
class Sidebar
{
public function __construct()
{
Menu::make('StuffsideBar', function ($menu) {
$menu->add('Link1', ['url' => '#', 'class' => 'tree-toggler nav-header'])
->add('Link 2', ['url' => '#', 'class' => 'tree-toggler nav-header'])
->add('Link 3', ['url' => '#', 'class' => 'tree-toggler nav-header']);
$about = $menu->add('about', ['url' => '#', 'class' => 'tree-toggler nav-header']);
$menu->about->add('index', ['url' => '#', 'class' => 'tree-toggler nav-header']);
$menu->about->add('index1', ['url' => '#', 'class' => 'tree-toggler nav-header'])
->add('index2', ['url' => '#', 'class' => 'tree-toggler nav-header'])
;
});
}
}
//sidebar.blade.php
@inject('sidebar','App\Sidebar')
<div class="container">
<div class="row">
<div class="well" style="width:300px; padding: 8px 0;">
<div style="overflow-y: scroll; overflow-x: hidden; height: 500px;">
{!! Menu::get('StuffsideBar')->asUl(['class' => 'nav nav-list'],['class' => 'nav nav-list tree']) !!}
</div>
</div>
</div>
</div>
// js
<script>
$(document).ready(function () {
$('li.tree-toggler > a').click(function () {
$(this).parent().children('ul').toggle(300);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment