@extends('layouts.app') @section('content')
Tickets
@can('create tickets') New Ticket @endcan

@php // ✅ Controller se $isAdmin pass karna recommended, fallback: $isAdmin = $isAdmin ?? auth()->user()->hasAnyRole(['admin','super admin','super-admin','super_admin']); @endphp @php $user = auth()->user(); @endphp @if($user && $user->hasAnyRole(['super admin','awqaf admin']))
{{-- ✅ Admin only extra filters --}} @if($isAdmin)
@endif
@endif @if(session('success')) @endif @if($tickets->count() > 0) @foreach($tickets as $ticket) @php $isOverdue = $ticket->sla_due && $ticket->sla_due->isPast() && !in_array($ticket->status, ['RESOLVED', 'CLOSED']); @endphp @endforeach
# Mosque Message Urgency Category Status SLA Due Assigned To Created Actions
{{ $loop->iteration }} {{ $ticket->mosque->name }} {{ Str::limit($ticket->message, 50) }} {{-- ✅ (optional) show raiser for admin --}} @if($isAdmin && $ticket->raiser)
By: {{ $ticket->raiser->name }} @endif
@php $urgencyColors = [ 'LOW' => 'success', 'NORMAL' => 'info', 'HIGH' => 'warning', 'URGENT' => 'danger' ]; @endphp {{ $urgencies[$ticket->urgency] ?? $ticket->urgency }} @if($ticket->category) {{ $ticket->category }} @else N/A @endif @php $statusColors = [ 'OPEN' => 'danger', 'ASSIGNED' => 'warning', 'IN_PROGRESS' => 'primary', 'RESOLVED' => 'info', 'CLOSED' => 'success' ]; @endphp {{-- ✅ make badge clickable only for admin --}} @if($isAdmin) {{ $statuses[$ticket->status] ?? $ticket->status }} @else {{ $statuses[$ticket->status] ?? $ticket->status }} @endif @if($ticket->sla_due) {{ $ticket->sla_due->format('d M Y, h:i A') }} @if($isOverdue)
Overdue @endif @else Not set @endif
@if($ticket->assignee) {{ $ticket->assignee->name }} @else Unassigned @endif {{ $ticket->created_at->format('d M Y') }}
@can('view tickets') @endcan @can('update tickets') @endcan @can('delete tickets')
@csrf @method('DELETE')
@endcan
@else
No tickets found. @can('create tickets') Create your first ticket @endcan
@endif
@endsection @push('script') @endpush