@extends('layouts.app') @section('title', 'User Management') @section('content') @include('partials.flash') @php $selInput = 'py-2.5 px-3 bg-surface-container rounded-lg border-none focus:ring-2 focus:ring-primary/20 text-body-md outline-none'; $curService = (int) request('service'); $curServiceName = optional($services->firstWhere('id', $curService))->name; $hasFilters = request()->hasAny(['q', 'role', 'service', 'status', 'login']); @endphp
search
{{-- Searchable location filter (handles a long service list) --}}
@if($hasFilters) Reset @endif
download Export CSV upload Bulk import person_add New User
@if($hasFilters)

{{ $users->total() }} {{ Str::plural('user', $users->total()) }} match your filters.

@endif {{-- Standalone bulk form (checkboxes attach via the form= attribute so the per-row delete forms are never nested inside it). --}}
@csrf
No users selected
@php $curSort = in_array(request('sort'), ['name','email','role','location','joined']) ? request('sort') : 'name'; $curDir = request('dir') === 'desc' ? 'desc' : 'asc'; $sortHeader = function ($col, $text, $extra = '') use ($curSort, $curDir) { $active = $curSort === $col; $nextDir = $active && $curDir === 'asc' ? 'desc' : 'asc'; $params = array_merge(\Illuminate\Support\Arr::except(request()->query(), ['page']), ['sort' => $col, 'dir' => $nextDir]); $icon = $active ? ($curDir === 'asc' ? 'arrow_upward' : 'arrow_downward') : 'unfold_more'; $iconCls = $active ? 'text-primary' : 'text-outline/50'; return '' .e($text).''.$icon.''; }; @endphp
@forelse($users as $user) @php $initials = collect(explode(' ', $user->name))->map(fn($n) => $n[0] ?? '')->take(2)->implode(''); $role = $user->roles->first()?->name; $roleBadge = match($role) { 'admin' => 'bg-primary/10 text-primary', 'hr' => 'bg-secondary-container text-on-secondary-container', 'trainer' => 'bg-surface-container-high text-secondary', default => 'bg-surface-container-high text-on-surface-variant', }; @endphp @empty @endforelse
{!! $sortHeader('name', 'User') !!} {!! $sortHeader('role', 'Role') !!} {!! $sortHeader('location', 'Location') !!} {!! $sortHeader('joined', 'Joined') !!} Actions
{{ strtoupper($initials) }}

{{ $user->name }}

{{ $user->email }}

{{ $role ? (($role === 'service_manager' && ($smLabel = \App\Models\User::smTitleLabel($user->sm_title))) ? $smLabel : (\App\Models\User::roleLabels()[$role] ?? \Illuminate\Support\Str::headline($role))) : 'No role' }} @php $loc = $user->locationLabel(); $others = $user->services->where('id', '<>', $user->location_service_id)->pluck('name')->sort()->values(); @endphp @if($loc) {{ $loc }} @if($others->isNotEmpty()) + {{ $others->count() > 2 ? $others->take(2)->implode(', ').' +'.($others->count() - 2).' more' : $others->implode(', ') }} @endif @else — @endif {{ $user->created_at?->format('j M Y') }}
monitoring @if($user->id !== auth()->id() && ! $user->hasRole('admin'))
@csrf
@endif edit @if($user->id !== auth()->id())
@csrf @method('DELETE')
@else lock @endif
No users found. Add one.
{{ $users->links() }}
@endsection