@php $link = fn ($pattern) => request()->routeIs($pattern) ? 'flex items-center gap-2 rounded-md bg-white/15 px-3 py-2 font-medium text-white' : 'flex items-center gap-2 rounded-md px-3 py-2 text-white/75 hover:bg-white/10 hover:text-white'; $groups = [ 'Daily work' => [ ['Dashboard', 'dashboard', 'dashboard', null], ['Counter sale', 'pos.index', 'pos.*', 'sale.create'], ['Orders', 'orders.index', 'orders.*', 'order.view'], ['Deliveries', 'trips.index', 'trips.*', 'delivery.manage'], ['Collections', 'receipts.index', 'receipts.*', 'receipt.create'], ], 'Plants' => [ ['Stock by size', 'stock.index', 'stock.*', 'stock.view'], ['Production', 'batches.index', 'batches.*', 'production.view'], ['Farmer collection','collections.index', 'collections.*', 'collection.view'], ['Raw materials', 'materials.index', 'materials.*', 'inventory.view'], ], 'Field sales' => [ ['Routes', 'routes.index', 'routes.*', 'route.view'], ['Shops', 'shops.index', 'shops.*', 'shop.view'], ['Visits', 'visits.index', 'visits.*', 'visit.view'], ['Vehicle stock', 'vehicles.stock', 'vehicles.*', 'vehicle.view'], ], 'Money' => [ ['Cashbook', 'cashbook.index', 'cashbook.*', 'cashbook.view'], ['Petty cash', 'pettycash.index', 'pettycash.*', 'cashbook.view'], ['Cheques', 'cheques.index', 'cheques.*', 'cheque.view'], ['Payroll', 'payroll.index', 'payroll.*', 'payroll.view'], ], 'Reports' => [ ['All reports', 'reports.index', 'reports.*', 'report.view'], ], 'Admin' => [ ['Company profile', 'admin.company.edit', 'admin.company.*', 'settings.manage'], ['Products', 'products.index', 'products.*', 'product.manage'], ['Users & roles', 'admin.users.index', 'admin.users.*', 'user.manage'], ['Payment methods', 'admin.payment-methods.index', 'admin.payment-methods.*', 'settings.manage'], ['SMS templates', 'admin.sms.index', 'admin.sms.*', 'settings.manage'], ], ]; @endphp @foreach ($groups as $heading => $items) @php $visible = collect($items)->filter(fn ($i) => $i[3] === null || auth()->user()?->hasPermission($i[3])); @endphp @if ($visible->isNotEmpty())

{{ $heading }}

@foreach ($visible as [$label, $route, $pattern, $permission]) @if (Route::has($route)) {{ $label }} @else {{ $label }} @endif @endforeach
@endif @endforeach