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

46 lines
1.6 KiB
PHP
Raw 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();
$calendar = $menu->add('Mon calendrier', ['route' => ['calendar', 'month'], 'class' => 'nav-item'])->nickname('calendar');
$calendar->link->attr(['class' => 'nav-link']);
$calendar->prepend('<i class="fe fe-calendar"></i> ');
$calendar->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);
}
}