<commit_before><?php

namespace Yajra\CMS\Http\Middleware;

use Caffeinated\Menus\Builder;
use Caffeinated\Menus\Facades\Menu;
use Closure;

class GenerateAdminMenu
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (auth()->check() && $request->is('administrator*')) {
            Menu::make('admin', function (Builder $menu) {
                $menu->add('Dashboard', route('administrator.index'))->icon('home');

                $navs = app('navigation')->getPublished();
                if ($navs->count()) {
                    $nav = $menu->add('Navigation', '#')->icon('sitemap')
                                ->data('permission', 'navigation.view');
                    $nav->add('Manage', route('administrator.navigation.index'))
                        ->icon('cogs')
                        ->data([
                            'permission' => 'navigation.view',
                            'append'     => route('administrator.navigation.create'),
                        ]);
                    $navs->each(function ($item) use ($nav) {
                        $nav->add($item->title, route('administrator.navigation.menu.index', $item->id))
                            ->icon('link')
                            ->data([
                                'permission' => 'navigation.view',
                                'append'     => route('administrator.navigation.menu.create', $item->id),
                            ]);
                    });
                } else {
                    $menu->add('Navigation', route('administrator.navigation.index'))->icon('link')
                         ->data(['permission' => 'navigation.view']);
                }

                $contents = $menu->add('Contents', '#')->icon('files-o');
                $contents->add('Articles', route('administrator.articles.index'))
                         ->icon('files-o')
                         ->data([
                             'permission' => 'article.view',
                             'append'     => route('administrator.articles.create'),
                         ]);
                $contents->add('Categories', route('administrator.categories.index'))
                         ->icon('file-text')
                         ->data([
                             'permission' => 'category.view',
                             'append'     => route('administrator.categories.create'),
                         ]);
                $contents->add('Widgets', route('administrator.widgets.index'))->icon('plug')
                         ->data([
                             'permission' => 'widget.view',
                             'append'     => route('administrator.widgets.create'),
                         ]);
                $contents->add('Media', route('administrator.media.index'))->icon('image')
                         ->data('permission', 'media.view');

                $mod     = $menu->add('Modules', '#')->icon('plug');
                $modules = app('modules')->all();
                collect($modules)->each(function ($module) use ($mod) {
                    /** @var \Pingpong\Modules\Module $module */
                    $mod->add($module->getStudlyName(), url("administrator/{$module->getLowerName()}"))->icon('file');
                });

                $menu->add('Themes', route('administrator.themes.index'))
                     ->icon('windows')
                     ->data(['permission' => 'theme.view']);

                $users = $menu->add('Users', '#')->icon('key');<commit_msg>Temp comment out modules menu.<commit_after><?php

namespace Yajra\CMS\Http\Middleware;

use Caffeinated\Menus\Builder;
use Caffeinated\Menus\Facades\Menu;
use Closure;

class GenerateAdminMenu
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (auth()->check() && $request->is('administrator*')) {
            Menu::make('admin', function (Builder $menu) {
                $menu->add('Dashboard', route('administrator.index'))->icon('home');

                $navs = app('navigation')->getPublished();
                if ($navs->count()) {
                    $nav = $menu->add('Navigation', '#')->icon('sitemap')
                                ->data('permission', 'navigation.view');
                    $nav->add('Manage', route('administrator.navigation.index'))
                        ->icon('cogs')
                        ->data([
                            'permission' => 'navigation.view',
                            'append'     => route('administrator.navigation.create'),
                        ]);
                    $navs->each(function ($item) use ($nav) {
                        $nav->add($item->title, route('administrator.navigation.menu.index', $item->id))
                            ->icon('link')
                            ->data([
                                'permission' => 'navigation.view',
                                'append'     => route('administrator.navigation.menu.create', $item->id),
                            ]);
                    });
                } else {
                    $menu->add('Navigation', route('administrator.navigation.index'))->icon('link')
                         ->data(['permission' => 'navigation.view']);
                }

                $contents = $menu->add('Contents', '#')->icon('files-o');
                $contents->add('Articles', route('administrator.articles.index'))
                         ->icon('files-o')
                         ->data([
                             'permission' => 'article.view',
                             'append'     => route('administrator.articles.create'),
                         ]);
                $contents->add('Categories', route('administrator.categories.index'))
                         ->icon('file-text')
                         ->data([
                             'permission' => 'category.view',
                             'append'     => route('administrator.categories.create'),
                         ]);
                $contents->add('Widgets', route('administrator.widgets.index'))->icon('plug')
                         ->data([
                             'permission' => 'widget.view',
                             'append'     => route('administrator.widgets.create'),
                         ]);
                $contents->add('Media', route('administrator.media.index'))->icon('image')
                         ->data('permission', 'media.view');

//                $mod     = $menu->add('Modules', '#')->icon('plug');
//                $modules = app('modules')->all();
//                collect($modules)->each(function ($module) use ($mod) {
//                    /** @var \Pingpong\Modules\Module $module */
//                    $mod->add($module->getStudlyName(), url("administrator/{$module->getLowerName()}"))->icon('file');
//                });

                $menu->add('Themes', route('administrator.themes.index'))
                     ->icon('windows')
                     ->data(['permission' => 'theme.view']);

                $users = $menu->add('Users', '#')->icon('key');
{'fraction_non_alphanumeric': 0.17071860308932169, 'fraction_numerical': 0.0, 'mean_word_length': 1.3578214059531348, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 125, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1202432', 'n_tokens_mistral': 1821, 'n_tokens_neox': 1727, 'n_words': 253}