journal-intime/app/Http/Middleware/GenerateMenus.php

41 lines
1.3 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Lavary\Menu\Builder;
use Lavary\Menu\Menu;
class GenerateMenus
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
(new Menu)->make('menu', function (Builder $menu) {
$accueil = $menu->add('Accueil', ['route' => 'dashboard', 'class' => 'nav-item'])->nickname('home');
$accueil->link->attr(['class' => 'nav-link']);
$accueil->prepend('<i class="fe fe-home"></i> ');
$accueil->checkActivationStatus();
$stats = $menu->add('Mes statistiques', ['route' => 'stats', 'class' => 'nav-item'])->nickname('stats');
$stats->link->attr(['class' => 'nav-link']);
$stats->prepend('<i class="fe fe-trending-up"></i> ');
$stats->checkActivationStatus();
$gallery = $menu->add('Ma gallerie', ['route' => 'gallery', 'class' => 'nav-item'])->nickname('gallery');
$gallery->link->attr(['class' => 'nav-link']);
$gallery->prepend('<i class="fe fe-image"></i> ');
$gallery->checkActivationStatus();
});
return $next($request);
}
}