<?php

namespace Modules\ActivityLog\Http\Controllers;

use App\Http\Controllers\Controller;

class DataController extends Controller
{
    /**
     * Called by ModuleUtil::getModuleData('modifyAdminMenu') in AdminSidebarMenu middleware.
     * Adds the Enhanced Activity Log entry to the admin sidebar.
     */
    public function modifyAdminMenu()
    {
        if (!auth()->user()->can('activity_log.view')) {
            return;
        }

        \Menu::modify('admin-sidebar-menu', function ($menu) {
            $menu->url(
                route('activity-log.index'),
                __('activityLog::lang.enhanced_activity_log'),
                [
                    'icon'   => 'fa fas fa-history',
                    'active' => request()->segment(1) === 'activity-log-module',
                ]
            )->order(36);
        });
    }
}
